Choose a sport and get the headlines.
Sports:
"" = all
"nhl" = NHL
"mlb" = MLB
"nba" = NBA
"college-football" = College football
"mens-college-basketball" = Mens college basketball
"racing/nascar" = NASCAR
| var request = require('request'); | |
| var cheerio = require('cheerio'); | |
| var sport = "nhl"; | |
| request('http://www.espn.com/' + sport, function(error, response, html){ | |
| if(!error){ | |
| var $ = cheerio.load(html); | |
| var headlines = [] | |
| $('.headlines li').each(function(i, elem){ | |
| headlines.push($(this).text()); | |
| }) | |
| console.log(JSON.stringify(headlines)); | |
| } else { | |
| console.log("Could not find espn headlines."); | |
| } | |
| }); |