[英]Node js Application cannot call method of undefined
我使用在https://www.npmjs.com/package/crawler-ninja中找到的Crawler Ninja插件與插件過期的域結合使用。 https://github.com/christophebe/expired-domains.ninja
但是,在我的第一次“嘗試”中,它返回了一些模糊的錯誤。 我相信是第一個錯字,我改了
console.log(ed.expireds.keys())
至
console.log(end.expireds.keys())
錯誤是:
console.log(ed.expireds.keys())
^
ReferenceError: ed is not defined
現在我面臨一個新的錯誤:
[root@vps-121706-2576 node_modules]# node ttt.js
Use log in : /root/plg/node_modules/logs/crawler.log
Well done Sir !, done in : 170389
/root/plg/node_modules/ttt.js:22
console.log(end.expireds.keys())
^
TypeError: Cannot call method 'keys' of undefined
題 :
不了解錯誤以及如何解決。 如果需要更多信息或詳細信息,請發表評論。
代碼插件:
var crawler = require("crawler-ninja");
var ep = require("crawler-ninja-expired");
crawl();
function crawl(){
var c = new crawler.Crawler({
externalDomains : true,
images : false,
scripts : false,
links : false, //link tags used for css, canonical, ...
followRedirect : true
});
var expired = new ep.Plugin(c);
c.on("end", function() {
var end = new Date();
console.log("Well done Sir !, done in : " + (end - start));
// the attributes expireds is a map with a key that match to the expired domains
console.log(end.expireds.keys())
});
var start = new Date();
c.queue({url : "http://www.erijane.nl/"});
}
end
是一個Date
對象,沒有expireds
屬性。
也許您只需要定義如下的expired
對象:
var expired = new ep.Plugin(c);
或者也許您需要ep
對象而不是ed
或end
。
說實話,我不知道圖書館,只是猜測。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.