【问题标题】:How to properly crawl through webpage with infinite scroll?如何通过无限滚动正确抓取网页?
【发布时间】:2016-05-06 20:02:12
【问题描述】:

如何从无限滚动的网站中抓取数据?

我要做的是从 Google Play 商店 (https://play.google.com/store/apps/category/GAME/collection/topselling_free?hl=en) 获取所有数据。

我正在使用 Apify(https://www.apify.com/) 来爬取 Google Play 商店;我想获取“Top Free in games”的所有链接,然后获取所有热门游戏的标题和详细信息。

很遗憾,当用户滚动到页面底部时,页面会加载新数据,而我不知道如何获取新数据。

这是我的页面功能:

function pageFunction(context) {
var $ = context.jQuery;
if (context.request.label === "DETAIL") {
    context.skipLinks();
    if($('.details-info .info-container .info-box-top .document-title .id-app-title').length >= 1) {
        return {
            title: $('.details-info .info-container .info-box-top .document-title .id-app-title').text(),
            publisher: $('.details-info .info-container .info-box-top .document-subtitles .primary').text(),
            genre: $('.details-info .info-container .info-box-top .document-subtitles .category').text(),
            rating: $('.details-wrapper .details-section .rating-box .score').text()
        };
    }
} else {
    context.skipOutput();
    $.post("https://play.google.com/store/apps/category/GAME/collection/topselling_free?hl=en&authuser=0");
}

}

如何加载其他游戏并获取它们的链接,以便在游戏页面上获取它们的详细信息?

非常感谢您提供示例或示例代码。

【问题讨论】:

  • 我认为每个“滚动”都是一个新页面、新链接、新请求。你应该走那条路。最终,你的爬虫已经有了一些方法来抓取这样的页面。

标签: javascript jquery ajax web-crawler apify


【解决方案1】:

高级设置下有一个名为无限滚动高度的选项,可以从无限滚动中抓取内容。检查Apify documentation

【讨论】:

  • 我读到了,但我认为这只是为了限制它滚动的距离。我现在觉得好傻。它就像我想要的那样工作,谢谢!
  • 此设置是否已弃用?
猜你喜欢
  • 2013-11-11
  • 1970-01-01
  • 2012-09-13
  • 2020-02-18
  • 1970-01-01
  • 2013-01-03
  • 2017-08-31
  • 2023-03-08
  • 1970-01-01
相关资源
最近更新 更多