解决phantomjs截图失败,phantom.exit位置的问题
刚刚学习使用phantomjs,根据网上帖子自己手动改了一个延时截图功能,发现延时功能就是不能执行,最后一点点排查出了问题。
看代码:
var page = require('webpage').create(),
system = require('system'),
address,file;
if (system.args.length === 1) {
console.log('Usage: netlog.js <some URL>');
phantom.exit(1);
} else {
address = system.args[1];
file = system.args[2];
page.open(address, function (status) {
if (status == 'success') {
console.log('success file is ' + file);
}
window.setTimeout(function ()
{
console.log('render ok');
page.render(file);
phantom.exit();//<span style="color:#ff0000;">必须在settimeout里面调用结束语句</span>
},60*1000);
});
}手动改的代码setTimeout里没有写phantom.exit(),而是放在setTimeout外面了,怎么都不能执行setTimeout里面的语句,放进去就ok了。。。
相关推荐
sfkong 2020-08-02
89500297 2020-05-05
delmarks 2020-04-09
gjcxywwx 2019-11-04
前端开发Kingcean 2019-10-22
Magicsoftware 2019-10-19
xuewenke 2012-02-05
jiangbo0 2019-09-08
85403263 2019-07-01
codable 2019-07-01
梦秋雨 2019-07-01
87241940 2019-06-30
83251242 2019-06-30
85281643 2019-06-29
whynotgonow 2019-06-29