Skip to content

Instantly share code, notes, and snippets.

@ariamoraine
Created August 24, 2012 19:46
Show Gist options
  • Save ariamoraine/3454942 to your computer and use it in GitHub Desktop.
Save ariamoraine/3454942 to your computer and use it in GitHub Desktop.
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