Created
July 14, 2011 09:09
-
-
Save notjosh/1082141 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 nodeio = require('node.io'); | |
exports.job = new nodeio.Job({max: 1, retries: 1, auto_retry: false, jsdom: true }, { | |
/* init: function () { | |
//The initial input is page 1 of search results | |
this.input = ["http://www.nuffieldtheatre.co.uk/events/category/C81/"]; | |
},*/ | |
input: ["http://www.nuffieldtheatre.co.uk/events/category/C81/"], | |
run: function (search_page) { | |
this.getHtml(search_page, function(err, $) { | |
//Handle any request / parsing errors | |
if (err) this.exit(err); | |
// console.log($('.listing h2')); | |
next_link = $('.paginate_links a:contains("Next")')[0] || false; | |
if (next_link) { | |
console.log("Next Page: "+next_link.href); | |
this.add(next_link.href); | |
} | |
//Scrape projects on the page and emit | |
var projects = []; | |
$('.listing').each(function (i, listing) { | |
var project = {}; | |
project.date = $(listing).find('.date').text().trim(); | |
projects.push(project); | |
}); | |
this.emit(projects); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment