PhantomJS 5-min Wiki phantom.exit() oddity
PhantomJS 5-min Wiki phantom.exit() oddity
所以维基的例子在这里有两个地方phantom.exit()
。为什么我不能把phantom.exit()
放在脚本的末尾?这对我来说没有太大意义。
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?
page.open
方法是异步的,因此传递给它的回调函数将在将来的某个时间点运行(当 address
引用的资源完成加载时)。
如果在该脚本末尾调用phantom.exit()
,PhantomJS 将在回调有机会执行之前退出。
相关文章:
- Node.js-等待process.exit()在前面的代码完成后执行
- enter() 和 exit() 如何检测 D3 中的更新数据
- PhantomJS 5-min Wiki phantom.exit() oddity
- exit().remove() 在 d3.js 更新之前不会删除旧图表
- “exit”- 从节点.js集群中的主进程终止时工作进程中的事件
- groups.exit(..).watchTransition不是一个函数
- 通过jQuery将DISPLAY:NONE添加到span,当:鼠标单击span外部,或单击EXIT按钮,等等+
- D3 TypeError: link.exit 不是函数 link.exit().remove();我做错了什么
- D3.js:enter(),update,exit(),中间有组元素
- PhantomJS在Linux上的phantom.exit()之后崩溃
- D3 SVG 图表中的现有元素不会更新 - 所有元素都被视为 exit() 和 enter() 集
- Expressjs/node.js相当于php中的exit()
- D3.js-exit()部分不会删除所有数据
- d3.js使用exit()和enter()进行减法转换
- .exit().remove()用于删除折线图图例中的文本,但不删除矩形
- clearTimeout on Mouse Exit
- node.js pm2 on exit
- process.exit钩子无限循环
- 等效于JavaScript中Python的sys.exit()
- 无法将phantom.exit()放入phantomjs中的page.eevaluate()中