I have copied example code from spookyjs npm web-page, but it does'nt print out anything. App keeps running, but nothing happens. What can be the reason?
Здравствуйте! Я скопировал код примера со страницы spookyjs на npmjs.com, но он ничего не выводит. Приложение при этом остается запущенным. В чем может быть причина?
Код / code:
try {
var Spooky = require('spooky2');
} catch (e) {
Spooky = require('node_modules/spooky2');
}
var spooky = new Spooky({
child: {
transport: 'http'
},
casper: {
logLevel: 'debug',
verbose: true
}
}, function (err) {
if (err) {
e = new Error('Failed to initialize SpookyJS');
e.details = err;
throw e;
}
spooky.start(
'http://en.wikipedia.org/wiki/Spooky_the_Tuff_Little_Ghost');
spooky.then(function () {
this.emit('hello', 'Hello, from ' + this.evaluate(function () {
return document.title;
}));
});
spooky.run();
});
spooky.on('error', function (e, stack) {
console.error(e);
if (stack) {
console.log(stack);
}
});
// Uncomment this block to see all of the things Casper has to say.
// There are a lot.
// He has opinions.
spooky.on('console', function (line) {
console.log(line);
});
spooky.on('hello', function (greeting) {
console.log(greeting);
});
spooky.on('log', function (log) {
if (log.space === 'remote') {
console.log(log.message.replace(/ \- .*/, ''));
}
});
via Светозар
No comments:
Post a Comment