Skip to content

Instantly share code, notes, and snippets.

@notjosh
Created July 14, 2011 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notjosh/1082141 to your computer and use it in GitHub Desktop.
Save notjosh/1082141 to your computer and use it in GitHub Desktop.
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