diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/MeituriRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/MeituriRipper.java index 4e39a985..8bdd2b2f 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/MeituriRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/MeituriRipper.java @@ -35,11 +35,11 @@ public class MeituriRipper extends AbstractHTMLRipper { @Override public String getGID(URL url) throws MalformedURLException { // without escape - // ^https?://[w.]*meituri\.com/a/([0-9]+)/([0-9\.html]+)*$ + // ^https?://[w.]*meituri\.com/a/([0-9]+)/([0-9]+\.html)*$ // https://www.meituri.com/a/14449/ // also matches https://www.meituri.com/a/14449/3.html etc. // group 1 is 14449 - Pattern p = Pattern.compile("^https?://[w.]*meituri\\.com/a/([0-9]+)/([0-9\\.html]+)*$"); + Pattern p = Pattern.compile("^https?://[w.]*meituri\\.com/a/([0-9]+)/([0-9]+\\.html)*$"); Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { albumID = m.group(1); @@ -59,27 +59,22 @@ public class MeituriRipper extends AbstractHTMLRipper { List imageURLs = new ArrayList<>(); // Get number of images from the page // Then generate links according to that - String numOfImages = ""; - // A very ugly way of getting "图片数量: 55P" from paragraphs - // 3rd p in div.tuji - int n = 0; + int numOfImages = 1; + Pattern p = Pattern.compile("^

图片数量: ([0-9]+)P

$"); for (Element para : doc.select("div.tuji > p")) { - // 图片数量: 55P - if (n == 2) { - numOfImages = para.toString(); + //

图片数量: 55P

+ Matcher m = p.matcher(para.toString()); + if (m.matches()) { + // 55 + numOfImages = Integer.parseInt(m.group(1)); } - n++; } - // ["

图片数量:", "55P

"] - String[] splitNumOfImages = numOfImages.split(" "); - // "55P

" -> "55" -> 55 - int actualNumOfImages = Integer.parseInt(splitNumOfImages[1].replace("P

", "")); // Base URL: http://ii.hywly.com/a/1/albumid/imgnum.jpg String baseURL = "http://ii.hywly.com/a/1/" + albumID + "/"; // Loop through and add images to the URL list - for (int i = 1; i <= actualNumOfImages; i++) { + for (int i = 1; i <= numOfImages; i++) { imageURLs.add(baseURL + i + ".jpg"); } return imageURLs;