Created
August 24, 2012 19:46
-
-
Save ariamoraine/3454942 to your computer and use it in GitHub Desktop.
This file contains 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 express = require('express'); | |
var app = express(); | |
var nodeio = require('node.io'); | |
var scraper = { | |
input: false, | |
run: function() { | |
this.getHtml('http://www.simplesteps.org/eat-local/state/new-york', function(err, $) { | |
//Handle any request / parsing errors | |
if (err) this.exit(err); | |
var listOfMonths = []; | |
// //Select all months on the page | |
$('div.season').each(function(season) { | |
var eachmonth = $('h3', season).children[0].raw; | |
var listOfVeggies = []; | |
$('a', season).each(function(veggie){ | |
listOfVeggies.push(veggie.children[0].raw); | |
}) | |
listOfMonths[eachmonth] = listOfVeggies; | |
}); | |
mylist = this.emit(listOfMonths); | |
console.log(listOfMonths); | |
}); | |
} | |
} | |
exports.job = new nodeio.Job({timeout:10}, scraper); | |
console.log(scraper.mylist + 'VVVVVVVVVVVVVVV') | |
app.get('/', function(req, res){ | |
res.send('hello world ' + scraper.listOfMonths); | |
}); | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment