我已經設置了一個腳本來創建我們的應用程序的網頁截圖。 它完美地運行,直到我遇到一個像一個破碎的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