簡體   English   中英

使用 Phantomjs/Pjscrape 抓取多個頁面

[英]Scraping multiple pages with Phantomjs/Pjscrape

試圖抓取多個頁面,但無法讓 urlid 數組在 pjscrape .js 文件中工作。

我很確定我可能會犯一個新手錯誤,但我會很感激一些幫助。 謝謝 :)

pjs.config({

    timeoutInterval: 6000,
    timeoutLimit: 10000,

})

pjs.addSuite({
    // single URL or array
    url: abolaURLs,
    scraper: function(){
        var abolaURLs = [366762,366764,366763];
        for (var i = 0; i<abolaURLs.length; i++) {
            abolaURLs[i] = 'http://abola.pt/nnh/ver.aspx?id=' + abolaURLs[i];
        };
        var results[];
        var cenas1 = $('div#a5g2').text();
        var cenas2 = $('span#noticiatext').text();
        var cenas3 = $('div#a5x').text();
        results.push(cenas1, cenas2, cenas3);
        return results;
    }
});

這對你有用:

var abolaURLs = [366762,366764,366763];

for (var i = 0; i < abolaURLs.length; i++) {
    abolaURLs[i] = 'http://abola.pt/nnh/ver.aspx?id=' + abolaURLs[i];
};

pjs.addSuite({
    url: abolaURLs,
    scraper: function() {
            var results = []; // !! you have the wrong array declaration result[]
            var cenas1 = $('div#a5g2').text();
            var cenas2 = $('span#noticiatext').text();
            var cenas3 = $('div#a5x').text();
            results.push(cenas1, cenas2, cenas3);
            return results;
    }
});

pjs.config({
    timeoutInterval: 6000,
    timeoutLimit: 10000,
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM