Last active
August 29, 2015 14:10
-
-
Save pkpp1233/222ecdd041fc0822c8a9 to your computer and use it in GitHub Desktop.
With Blockspring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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