Control CasperJS from your nodejs application.
Allow you to write powerful scraping scripts in nodeJs, by using CasperJS from nodeJs.
Install the dependencies:
sudo npm install -g phantomjs casperjs
npm install
casper.then(fn_in_current_context, null);
casper.then(fn_in_casperjs_context, fn_in_current_context);
Create a nodejs script.
var casper_nodejs = require('../../index.js');
var url = "http://google.com";
// load the page refered with 'url' with casper
var casper = casper_nodejs.create(url, {});
// once the page is loaded, execute that in our current nodejs context
casper.then(function executed_in_this_context() {
console.log("page loaded");
});
// then, execute that in casperjs, and the second callback in the current nodejs context
casper.then(function executed_in_casperjs_context() {
return 42;
}, function executed_in_this_context(ret) {
console.log("it works: " + ret);
// casper.exit() can be placed here too, instead of in the bottom :)
// casper.exit();
});
// exit casper after executing the 2 previous 'then'
casper.exit();
casper.create() spawns a child (casper-child), which:
In the nodejs context:
Project under MIT License (see the file LICENSE).