|
|
@@ -167,20 +167,24 @@ public class Sex8Tool {
|
|
|
return mCurrentPage != 0;
|
|
|
}
|
|
|
|
|
|
- private static String getTitles(Element docElement) {
|
|
|
+ private static String getTitle(Element docElement) {
|
|
|
Elements itemElementList = docElement.getElementsByTag("title");
|
|
|
if (itemElementList != null && itemElementList.size() > 0) {
|
|
|
String titleExtra = itemElementList.get(0).text();
|
|
|
- if (!TextUtils.isEmpty(titleExtra) && titleExtra.contains("杏吧")) {
|
|
|
- int index = titleExtra.indexOf("杏吧");
|
|
|
- if (index > 1) {
|
|
|
- index = index - 1;
|
|
|
+ if (!TextUtils.isEmpty(titleExtra)) {
|
|
|
+ if (titleExtra.contains("杏吧")) {
|
|
|
+ int index = titleExtra.indexOf("杏吧");
|
|
|
+ if (index > 1) {
|
|
|
+ index = index - 1;
|
|
|
+ }
|
|
|
+ return titleExtra.substring(0, index);
|
|
|
+ } else {
|
|
|
+ return titleExtra;
|
|
|
}
|
|
|
- return titleExtra.substring(0, index);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
+ return "未知";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -220,24 +224,35 @@ public class Sex8Tool {
|
|
|
if (magnetInfoElementList != null && magnetInfoElementList.size() > 0) {
|
|
|
MagnetBean magnetBean = new MagnetBean();
|
|
|
magnetBean.text = magnetInfoElementList.get(0).text();
|
|
|
- // todo 客户端查找的时候,返回去的要拼上BASIC_URL
|
|
|
+ // todo 客户端查找的时候,返回去的要拼上BASIC_URL,做成一个在数据库可配置的字段
|
|
|
magnetBean.url = magnetInfoElementList.get(0).attr("href");
|
|
|
magnetBean.goodsBean = goodsBean;
|
|
|
magnetBeanList.add(magnetBean);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // 描述
|
|
|
String description = "暂无描述";
|
|
|
Elements descElementList = document.getElementsByClass("b_pr");
|
|
|
if (descElementList != null && descElementList.size() > 0) {
|
|
|
- // todo 做正则剔除,或者客户端使用的时候,要使用WebView加载。先尝试WebView加载的
|
|
|
+ // 做正则剔除,或者客户端使用的时候,要使用WebView加载。先尝试WebView加载的
|
|
|
description = descElementList.get(0).parent().text();
|
|
|
+ if (!TextUtils.isEmpty(description)) {
|
|
|
+ if (description.contains("【")) {
|
|
|
+ int start = description.indexOf("【");
|
|
|
+ int end = description.lastIndexOf("【");
|
|
|
+ if (start < end) {
|
|
|
+ description = description.substring(start, end);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ description = "暂无描述";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 保存到数据库
|
|
|
if (photoList.size() > 0 && magnetBeanList.size() > 0) {
|
|
|
- goodsBean.title = getTitles(document);
|
|
|
+ goodsBean.title = getTitle(document);
|
|
|
goodsBean.description = description;
|
|
|
goodsBean.magnetBeanList.addAll(magnetBeanList);
|
|
|
goodsBean.contentImageUrlList.addAll(photoList);
|