Skip to content

Instantly share code, notes, and snippets.

@pkpp1233
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save pkpp1233/222ecdd041fc0822c8a9 to your computer and use it in GitHub Desktop.

Select an option

Save pkpp1233/222ecdd041fc0822c8a9 to your computer and use it in GitHub Desktop.
With Blockspring
var request = require('request');
var cheerio = require('cheerio');
var blockspring = require('blockspring');
blockspring.define(function(req, res){
request('http://www.espn.com/' + req.params['sport'], function(error, response, html){
if(!error){
var $ = cheerio.load(html);
var headlines = []
$('.headlines li').each(function(i, elem){
headlines.push($(this).text());
})
res.addOutput('headlines', headlines);
res.end();
} else {
res.addErrorOutput('Could not find espn headlines.');
res.end();
}
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment