从使用无限滚动的网页解析html

问题描述 投票:1回答:1

我想从使用无限滚动的网页解析html,例如:pinterest.com以获取所有项目。

public List<String> popularTagsPinterest(String tag) throws Exception {

    List<String> results = new ArrayList<>();
    try {
        Document doc = Jsoup.connect(
                urlPinterest + tag + "&eq=%23" + tag + "&etslf=6622&term_meta[]=%23" + tag + "%7Cautocomplete%7C0")
                .timeout(90000).get();
        Elements img1 = doc.select("a.pinImageWrapper img.pinImg");
        for (Element e : img1) {
            results.add(e.attr("src"));
            System.out.println(e.attr("src"));
        }
    } catch (Exception e) {
        e.printStackTrace();

    }
    return results;
}
java jsoup
1个回答
0
投票

获取基本URL和加载另一部分的ajax调用可以做到。

查看此页面,就是一个很好的例子。

https://blog.scrapinghub.com/2016/06/22/scrapy-tips-from-the-pros-june-2016

© www.soinside.com 2019 - 2024. All rights reserved.