Итак, пример из wiki имеет phantom.exit()
в двух местах здесь. Почему я не могу просто положить phantom.exit()
в конце скрипта? Это не имеет для меня слишком большого смысла.PhantomJS 5-min Wiki phantom.exit() oddity
var page = require('webpage').create(),
t, address;
if (phantom.args.length === 0) {
console.log('Usage: loadspeed.js <some URL>');
phantom.exit(); //Why does this only work if "phantom.exit()" is here,
} else {
t = Date.now();
address = phantom.args[0];
page.open(address, function (status) {
if (status !== 'success') {
console.log('FAIL to load the address');
} else {
t = Date.now() - t;
console.log('Loading time ' + t + ' msec');
}
phantom.exit(); //and here.
});
}
// but not just a single one here?