use of com.hippo.ehviewer.client.exception.ParseException in project EhViewer by seven332.
the class GalleryPageParser method parse.
public static Result parse(String body) throws ParseException {
Matcher m;
Result result = new Result();
m = PATTERN_IMAGE_URL.matcher(body);
if (m.find()) {
result.imageUrl = StringUtils.unescapeXml(StringUtils.trim(m.group(1)));
}
m = PATTERN_SKIP_HATH_KEY.matcher(body);
if (m.find()) {
result.skipHathKey = StringUtils.unescapeXml(StringUtils.trim(m.group(1)));
}
m = PATTERN_ORIGIN_IMAGE_URL.matcher(body);
if (m.find()) {
result.originImageUrl = StringUtils.unescapeXml(m.group(1)) + "fullimg.php" + StringUtils.unescapeXml(m.group(2));
}
if (!TextUtils.isEmpty(result.imageUrl)) {
return result;
} else {
throw new ParseException("Parse image url and skip hath key error", body);
}
}
use of com.hippo.ehviewer.client.exception.ParseException in project EhViewer by seven332.
the class ProfileParser method parse.
public static Result parse(String body) throws ParseException {
try {
Result result = new Result();
Document d = Jsoup.parse(body);
Element profilename = d.getElementById("profilename");
result.displayName = profilename.child(0).text();
try {
result.avatar = profilename.nextElementSibling().nextElementSibling().child(0).attr("src");
if (TextUtils.isEmpty(result.avatar)) {
result.avatar = null;
} else if (!result.avatar.startsWith("http")) {
result.avatar = EhUrl.URL_FORUMS + result.avatar;
}
} catch (Exception e) {
Log.i(TAG, "No avatar");
}
return result;
} catch (Exception e) {
throw new ParseException("Parse forums error", body);
}
}
Aggregations