-
-
Notifications
You must be signed in to change notification settings - Fork 142
npm module
Maciej Brencz edited this page Dec 25, 2013
·
9 revisions
phantomas can be used as CommonJS module from within your nodejs code:
npm install phantomas --save
This will install phantomas from npm repository and add a dependency to your project package.json
file.
var phantomas = require('phantomas'),
task;
console.log(phantomas.version); // 0.9.0
task = phantomas(url, options, function(err, res) {
// err: exit code
// res: parsed JSON or raw data (TAP / CSV / XML)
});
console.log(task.pid); // process ID
// Streams handling
task.stdout.pipe(process.stdout);
task.stderr.pipe(process.stderr);
// Events handling
task.on('progress', function(progress) {
// ...
});
task.on('results', function(results) {
// raw data (formatted as specified by --format option)
});
task.on('data', function(data) {
// parsed JSON results (in --format=json)
});
task.on('error', function(err) {
// ..
});