我可以使用node.js cherrio解析器从espncricinfo获得各个玩家的得分

时间:2014-05-07 14:01:44

标签: javascript node.js

我试图从espncricinfo获取各个玩家的得分和得分,但我无法找回它:

我只得到一些数据而不是得分,因为数据是动态的,这就是我无法得到这些数据的原因。

我的node.js代码如下:

 app.get('/scrape', function(req, res){
url = 'http://www.espncricinfo.com/indian-premier-league
              -2014/engine/match/733985.html';

request(url, function(error, response, html){
    if(!error){
        var $ = cheerio.load(html);
        $('td.batsman-name').filter(function(){
                var data = $(this);
                console.log("Hi Entered");
                console.log(data.text());
        })
     }

但我没有结果。

1 个答案:

答案 0 :(得分:1)

在我看来,您连接的网站会动态加载您要抓取的数据,因此您最有可能在不完整的html上使用cheerio。你可能会找出他们用来加载信息的数据的网址,然后把它刮掉。