我将如何去从无限滚动的网站上抓取数据?如何正确抓取无限滚动的网页?
我想要做的是从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");
}
}
我如何可以加载更多的游戏,并得到他们的链接,这样我可以得到游戏页面上的细节?
一个例子或示例代码将不胜感激。
我认为每个“滚动”是一个新的页面,新的链接,新的要求。你应该走那条路。最终,您的抓取工具已经有一些方法来抓取这样的网页。 –