无法使用 cheerio 抓取异步脚本

Unable to scrape async script with cheerio

我正在使用 cheerio 制作爬虫,但在某些网站中,脚本是异步的,当我尝试从中获取所有脚本时,它们没有被选中。 这是我使用的代码:

function Test(webUrl) {
    request(webUrl, function(err, resp, html){
        if(!err && resp.statusCode == 200) {
            var $ = cheerio.load(html);
            console.log($('script'));
        }
    });
}

有人有解决办法吗?谢谢

您需要使用 PhantomJS 来抓取动态内容。

示例如下:http://code4node.com/snippet/web-scraping-with-node-and-phantomjs