Skip to content
This repository was archived by the owner on Sep 4, 2021. It is now read-only.

Commit 01fa823

Browse files
committed
fix manhuaDB(#286)
1 parent e67b3c9 commit 01fa823

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

app/src/main/java/com/hiroshi/cimoc/source/ManHuaDB.java

+16-20
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alibaba.fastjson.JSON;
44
import com.alibaba.fastjson.JSONArray;
55
import com.alibaba.fastjson.JSONObject;
6+
import com.google.gson.JsonObject;
67
import com.hiroshi.cimoc.model.Chapter;
78
import com.hiroshi.cimoc.model.Comic;
89
import com.hiroshi.cimoc.model.ImageUrl;
@@ -71,7 +72,7 @@ public SearchIterator getSearchIterator(String html, int page) {
7172
protected Comic parse(Node node) {
7273
String cid = node.hrefWithSplit(1);
7374
String title = node.attr("title");
74-
String cover = node.attr("img", "src");
75+
String cover = node.attr("img", "data-original");
7576
return new Comic(TYPE, cid, title, cover, null, null);
7677
}
7778
};
@@ -120,31 +121,26 @@ public Request getImagesRequest(String cid, String path) {
120121
@Override
121122
public List<ImageUrl> parseImages(String html) {
122123
List<ImageUrl> list = new ArrayList<>();
123-
Document document = Jsoup.parse(html);
124124

125-
//获取页面定义的图片host和pre
126-
Element urlDefine = document.select(".vg-r-data").first();
127-
String imageHost = urlDefine.attr("data-host").trim();
128-
String imagePre = urlDefine.attr("data-img_pre").trim();
129-
130-
//获取页面定义的图片信息变量img_data
131-
String imageArrDataDefine = document.getElementsByTag("script").eq(7).first().html();
132-
imageArrDataDefine = imageArrDataDefine.substring(16, imageArrDataDefine.length() - 2);
133-
//进行base64转换
134125
try {
135-
imageArrDataDefine = DecryptionUtils.base64Decrypt(imageArrDataDefine);
126+
final String imageHost = StringUtils.match("data-host=\"(.*?)\"", html, 1);
127+
final String imagePre = StringUtils.match("data-img_pre=\"(.*?)\"", html, 1);
128+
final String base64Data = StringUtils.match("var img_data = '(.*?)';", html, 1);
129+
final String jsonStr = DecryptionUtils.base64Decrypt(base64Data);
130+
final JSONArray imageList = JSON.parseArray(jsonStr);
131+
132+
for(int i = 0; i < imageList.size(); i++ ) {
133+
final JSONObject image = imageList.getJSONObject(i);
134+
135+
final String imageUrl = imageHost + imagePre + image.getString("img");
136+
137+
list.add(new ImageUrl(image.getIntValue("p"), imageUrl, false));
138+
}
139+
136140
} catch (Exception e) {
137141
e.printStackTrace();
138-
return list;
139142
}
140143

141-
JSONArray imageList = JSON.parseArray(imageArrDataDefine);
142-
JSONObject image;
143-
int total = imageList.size();
144-
for (int i = 0; i < total; i++) {
145-
image = imageList.getJSONObject(i);
146-
list.add(new ImageUrl(image.getIntValue("p"), imageHost + imagePre + image.getString("img"), false));
147-
}
148144
return list;
149145
}
150146

0 commit comments

Comments
 (0)