我已经设置了一个脚本来创建我们的应用程序的webshots.它运行完美,一切正常直到我遇到一个破坏网址的图像:
"<img src='http://testserver.our.intranet/fetch/image/373e8fd2339696e2feeb680b765d626e' />"
Run Code Online (Sandbox Code Playgroud)
我已经设法在使用下面的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 …Run Code Online (Sandbox Code Playgroud)