org.jsoup.nodes.Document.select()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(439)

本文整理了Java中org.jsoup.nodes.Document.select()方法的一些代码示例,展示了Document.select()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.select()方法的具体详情如下:
包路径:org.jsoup.nodes.Document
类名称:Document
方法名:select

Document.select介绍

暂无

代码示例

代码示例来源:origin: square/retrofit

@Override public Page convert(ResponseBody responseBody) throws IOException {
  Document document = Jsoup.parse(responseBody.string());
  List<String> links = new ArrayList<>();
  for (Element element : document.select("a[href]")) {
   links.add(element.attr("href"));
  }
  return new Page(document.title(), Collections.unmodifiableList(links));
 }
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> result = new ArrayList<>();
  for (Element el : doc.select("ul.gallery-b > li > a")) {
    result.add(el.attr("href"));
  }
  return result;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getAlbumsToQueue(Document doc) {
  List<String> urlsToAddToQueue = new ArrayList<>();
  for (Element elem : doc.select(".post > li > div > div > a")) {
    urlsToAddToQueue.add(elem.attr("href"));
  }
  return urlsToAddToQueue;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document page) {
  List<String> imageURLs = new ArrayList<>();
  Elements thumbs = page.select("#gdt > .gdtm a");
  // Iterate over images on page
  for (Element thumb : thumbs) {
    imageURLs.add(thumb.attr("href"));
  }
  return imageURLs;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document page) {
  List<String> imageURLs = new ArrayList<>();
  Elements albumElements = page.select("a.highslide");
  for (Element imageBox : albumElements) {
    String imageUrl = imageBox.attr("href");
    imageURLs.add(imageUrl);
  }
  return imageURLs;
}

代码示例来源:origin: RipMeApp/ripme

public List<String> getURLsFromPage(Document doc) {
  List<String> imageURLs = new ArrayList<>();
  for (Element thumb : doc.select("a[target=_blank]")) {
    imageURLs.add(thumb.attr("href"));
  }
  return imageURLs;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getAlbumsToQueue(Document doc) {
  List<String> urlsToAddToQueue = new ArrayList<>();
  for (Element elem : doc.select("#post_masonry > article > div > figure > a")) {
    urlsToAddToQueue.add(elem.attr("href"));
  }
  return urlsToAddToQueue;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document page) {
  List<String> result = new ArrayList<>();
  for (Element el : page.select(".gallery-icon > a")) {
    result.add(el.attr("href"));
  }
  return result;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> imageURLs = new ArrayList<>();
  for (Element thumb : doc.select("a[data-lightbox=\"gallery\"]")) {
    String image = thumb.attr("href");
    imageURLs.add("https:" + image);
  }
  return imageURLs;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> imageURLs = new ArrayList<>();
  for (Element thumb : doc.select("div > a[target=_blank]:not(.footera)")) {
    imageURLs.add(thumb.attr("href"));
  }
  return imageURLs;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getAlbumsToQueue(Document doc) {
  List<String> urlsToAddToQueue = new ArrayList<>();
  for (Element elem : doc.select(".nav-chapters > li > div.media > a")) {
    urlsToAddToQueue.add(elem.attr("href"));
  }
  return urlsToAddToQueue;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> results = new ArrayList<>();
  Elements videos = doc.select("video");
  Element video = videos.get(0);
  results.add(video.attr("src"));
  return results;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document page) {
  Elements elements = page.select("div > span.thumb > a");
  List<String> res = new ArrayList<>();
  for (Element e : elements) {
    if (!e.attr("href").isEmpty()) {
      res.add(e.attr("abs:href"));
    }
  }
  return res;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> result = new ArrayList<>();
    for (Element el : doc.select("div.single-post > div.gallery > dl > dt > a > img")) {
      String imageSource = el.attr("data-lazy-src");
      // We remove the .md from images so we download the full size image
      // not the thumbnail ones
        imageSource = imageSource.replaceAll("-\\d\\d\\dx\\d\\d\\d", "");
        result.add(imageSource);
      }
    return result;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> result = new ArrayList<>();
    for (Element el : doc.select("a.image-container > img")) {
      String imageSource = el.attr("src");
      // We remove the .md from images so we download the full size image
      // not the medium ones
      imageSource = imageSource.replace(".md", "");
      result.add(imageSource);
    }
  return result;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> imageURLs = new ArrayList<>();
  Elements thumbs = doc.select("img.thumbnail");
  for (Element thumb : thumbs) {
    String link = thumb.attr("src").replaceAll("thumbs/th_", "");
    String imgSrc = "http://nude-gals.com/" + link;
    imageURLs.add(imgSrc);
  }
  return imageURLs;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> result = new ArrayList<String>();
  for (Element el : doc.select("div.block-content > div > div.img-container > a > img.img-responsive")) {
    String imageURL = "https:" + el.attr("src");
    imageURL = imageURL.replace("hentaicdn.com", "static.hentaicdn.com");
    imageURL = imageURL.replace("thumbnails/", "");
    imageURL = imageURL.replace("tmb", "");
    result.add(imageURL);
  }
    return result;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document page) {
  List<String> imageURLs = new ArrayList<>();
  Elements thumbs = page.select("a.gallerythumb > img");
  for (Element el : thumbs) {
    imageURLs.add(el.attr("data-src").replaceAll("t\\.n", "i.n").replaceAll("t\\.", "."));
  }
  return imageURLs;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document doc) {
  List<String> result = new ArrayList<>();
  for (Element el : doc.select("img.thumbnail")) {
    String imageSource = el.attr("src");
    imageSource = imageSource.replaceAll("_data/i", "");
    imageSource = imageSource.replaceAll("-\\w\\w_\\w\\d+x\\d+", "");
    result.add("https://theyiffgallery.com" + imageSource);
  }
  return result;
}

代码示例来源:origin: RipMeApp/ripme

@Override
public List<String> getURLsFromPage(Document page) {
  List<String> imageURLs = new ArrayList<>();
  for (Element thumb : page.select("div.item.asset img")) {
    String image = thumb.attr("src");
    image = image
        .replaceAll("/medium/", "/large/")
        .replaceAll("/small/", "/large/");
    imageURLs.add(image);
  }
  return imageURLs;
}

相关文章