@Test public void testParse() throws IOException, ParseException { InputStream resource = GalleryPageParserTest.class.getResourceAsStream("GalleryPageParserTest.html"); BufferedSource source = Okio.buffer(Okio.source(resource)); String body = source.readUtf8(); GalleryPageParser.Result result = GalleryPageParser.parse(body); assertEquals("http: assertEquals("26664-430636", result.skipHathKey); assertEquals("https: assertEquals("ghz0e5m98a4", result.showKey); }
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)); } m = PATTERN_SHOW_KEY.matcher(body); if (m.find()) { result.showKey = m.group(1); } if (!TextUtils.isEmpty(result.imageUrl) && !TextUtils.isEmpty(result.showKey)) { return result; } else { throw new ParseException("Parse image url and show error", body); } }
GalleryPageParser { 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)); } m = PATTERN_SHOW_KEY.matcher(body); if (m.find()) { result.showKey = m.group(1); } if (!TextUtils.isEmpty(result.imageUrl) && !TextUtils.isEmpty(result.showKey)) { return result; } else { throw new ParseException("Parse image url and show error", body); } } }
GalleryPageParser { 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)); } m = PATTERN_SHOW_KEY.matcher(body); if (m.find()) { result.showKey = m.group(1); } if (!TextUtils.isEmpty(result.imageUrl) && !TextUtils.isEmpty(result.showKey)) { return result; } else { throw new ParseException("Parse image url and show error", body); } }  }
GalleryPageParser { 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)); } m = PATTERN_SHOW_KEY.matcher(body); if (m.find()) { result.showKey = m.group(1); } if (!TextUtils.isEmpty(result.imageUrl) && !TextUtils.isEmpty(result.showKey)) { return result; } else { throw new ParseException("Parse image url and show error", body); } }  static Result parse(String body); }
GalleryPageParser { 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)); } m = PATTERN_SHOW_KEY.matcher(body); if (m.find()) { result.showKey = m.group(1); } if (!TextUtils.isEmpty(result.imageUrl) && !TextUtils.isEmpty(result.showKey)) { return result; } else { throw new ParseException("Parse image url and show error", body); } }  static Result parse(String body);  }