Skip to content

Instantly share code, notes, and snippets.

@cpietsch
Created May 24, 2013 17:58
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cpietsch/5645324 to your computer and use it in GitHub Desktop.
Save cpietsch/5645324 to your computer and use it in GitHub Desktop.
run spooky.js in a recursive mode multiple times
var Spooky, config, i, run_spooky, scraping, spooky, spooky_is_ready;
Spooky = require('spooky');
config = {
child: {
port: 8081
}
};
spooky = null;
i = 1;
scraping = function() {
console.log("new")
spooky.start("http://www.chrispie.com");
spooky.thenEvaluate(function () {
console.log('Hello, from', document.title);
});
return spooky.run();
};
spooky_is_ready = function(err, res) {
spooky.on('console', function(line) {
return console.log(line);
});
spooky.on('run.complete', function(){
console.log("FINISH");
spooky.destroy();
spooky = new Spooky(config, scraping);
})
return scraping();
};
spooky = new Spooky(config, spooky_is_ready);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment