2016-05-06 43 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