samedi 7 mai 2016

Web Scraping NBA.com

I am trying to return the text found at http://ift.tt/1SVDIMl at this tag

 <h4 class="nbaModTopTeamNum  win">95</h4> 

I am using NodeJS and Cheerio but everytime I console.log the $.text() I get a blank line. Here is my code:

 1 var request = require('request');
 2 var cheerio = require('cheerio');                                             
 3 var fs = require('fs');                                                       
 4 request('http://ift.tt/1SVDIMl', function(err, res,html){     
 5    if(!err && res.statusCode == 200){                                        
 6                                                                              
 7         var $ = cheerio.load(html);                                           
 8         var score = $('h4.nbaModTopTeamNum.win');                             
 9         console.log(score.text());                                            
 10    }                                                                         
 11    else console.log('Error reaching  host');                                  
 12});




Aucun commentaire:

Enregistrer un commentaire