2016-05-06 42 views
1

我将如何去从无限滚动的网站上抓取数据?如何正确抓取无限滚动的网页?

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

我使用Apify(https://www.apify.com/)在Google Play商店中抓取;我想要获得'最佳免费游戏'的所有链接,然后获得顶级游戏的所有标题和详细信息。

不幸的是,页面在用户滚动到页面底部时加载新数据,我无法弄清楚如何获取新数据。

这是我的页面功能:

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"); 
} 

}

我如何可以加载更多的游戏,并得到他们的链接,这样我可以得到游戏页面上的细节?

一个例子或示例代码将不胜感激。

+0

我认为每个“滚动”是一个新的页面,新的链接,新的要求。你应该走那条路。最终,您的抓取工具已经有一些方法来抓取这样的网页。 –

回答

2

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

+0

我读到了,但我认为这只是限制它将滚动多远。我现在感觉很愚蠢。它按照我的意愿工作,谢谢! – ScrawnySquirrel