我已经设置了一个脚本来创建我们的应用程序的网页截图。 它完美地运行,直到我遇到一个像一个破碎的URL所有的罚款:phantomJS网页超时
"<img src='http://testserver.our.intranet/fetch/image/373e8fd2339696e2feeb680b765d626e' />"
我已成功地打破了脚本中使用低于6秒后,它只是循环永远之前。
但是,是否有可能忽略网络请求(AKA
取出来的图像的DOM
),然后进行无图像创建拇指,(或注入的图像丢失的形象!)
var page = require('webpage').create(),
system = require('system'),
address, output, size;
if (system.args.length < 3 || system.args.length > 5) {
phantom.exit(1);
} else {
address = system.args[1];
output = system.args[2];
page.viewportSize = { width: 640, height: 640 };
page.zoomFactor = 0.75;
page.clipRect = { top: 10, left: 0, width: 640, height: 490 };
try{
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit();
} else {
window.setTimeout(function() {
page.render(output);
phantom.exit();
}, 200);
}
});
} finally{
setTimeout(function() {
console.log("Max execution time " + Math.round(6000) + " seconds exceeded");
phantom.exit(1);
}, 6000);
}
}
这是一个很好的问题。我们有一个类似的问题,除了有点难以解决。我们有一个客户的网站,它的自定义JavaScript写得不好。这似乎是导致webkit挂起。我们有大量想要测试的网站,但如果客户的自定义js正在破坏webkit,则它不起作用。计时器OBJ是一个很好的解决方案,但我想知道是否有人有差异解决方案。 ...? – cliffbarnes