我的剧本后,工作细到目前为止,sequentiell为了通过线加载文本文件的行每一页(page.open是asynchron和页面对象是全球覆盖=新的要求,这是一个大clusterfuck运行多个page.open()一次),匹配用于从它的特定域和印刷JSON值的每个请求。PhantomJS崩溃150-180网址
但是,如果我用一个.txt文件超过150〜链接,它只是崩溃每一次,大多是没有错误消息,并没有崩溃转储这样的:
PhantomJS已崩溃。请务必阅读正文 http://phantomjs.org/crash-reporting.html崩溃报告指南,并在 https://github.com/ariya/phantomjs/issues/new发送错误报告。 不幸的是,没有崩溃转储可用。 (为%TEMP%(C:\用户\ XXX \应用程序数据\本地的\ Temp),你可以不写的目录)
我可以重现,很容易,如果我多次运行它,不要紧,如果我一次或一次完成。 如何防止崩溃?如果Phantom无法处理,我的脚本就没用了。
但有时我得到一个崩溃转储:
PhantomJS已崩溃。请务必阅读正文 http://phantomjs.org/crash-reporting.html崩溃报告指南,并在 https://github.com/ariya/phantomjs/issues/new发送错误报告。 请附上崩溃转储文件: C:\用户\ XXX \应用程序数据\本地的\ Temp \ a4fd6af6-1244-44d3-8938-3aabe298c2fa.dmp
并且在极少数情况下我甚至会收到一条错误消息,Process Explorer说该进程一次最多有21个线程
的QThread ::开始:无法创建线程()
console.log('Hello, world!');
var fs = require('fs');
var stream = fs.open('500sitemap.txt', 'r');
var webPage = require('webpage');
var i = 1;
var hasFound = Array();
var hasonLoadFinished = Array();
function handle_page(line) {
var page = webPage.create();
page.settings.loadImages = false;
page.open(line, function() {});
page.onResourceRequested = function(requestData, request) {
var match = requestData.url.match(/example.de\/ac/g)
if (match != null) {
hasFound[line] = true;
var targetString = decodeURI(JSON.stringify(requestData.url));
var klammerauf = targetString.indexOf("{");
var jsonobjekt = targetString.substr(klammerauf, (targetString.indexOf("}") - klammerauf) + 1);
targetJSON = (decodeURIComponent(jsonobjekt));
var t = JSON.parse(targetJSON);
console.log(i + " " + t + " " + t['id']);
request.abort;
} else {
//hasFound = false;
return;
}
};
page.onLoadFinished = function(status) {
if (!hasonLoadFinished[line]) {
hasonLoadFinished[line] = true;
if (!hasFound[line]) {
console.log(i + " :NOT FOUND: " + line);
console.log("");
}
i++;
setTimeout(page.close, 200);
nextPage();
}
}
};
function nextPage() {
var line = stream.readLine();
if (!line) {
end = Date.now();
console.log("");
console.log(((end - start)/1000) + " Sekunden");
phantom.exit(0);
}
hasFound[line] = false;
hasonLoadFinished[line] = false;
handle_page(line);
}
start = Date.now();
nextPage();