Node . js应用程序不能调用未定义的方法

Node js Application cannot call method of undefined

本文关键字:未定义 方法 调用 不能 js 应用程序 Node      更新时间:2023-09-26

我使用Crawler Ninja插件,在https://www.npmjs.com/package/crawler-ninja与插件过期域名相结合。https://github.com/christophebe/expired-domains.ninja

然而,在我的第一次"尝试",它返回了我一些模糊的错误。第一个应该是打字错误,我改了

console.log(ed.expireds.keys())

console.log(end.expireds.keys())

ERROR WAS:

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

问题:

不明白错误和如何修复它。如果需要更多的信息或细节,请评论。

CODE PLUGIN:

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/"});
}

endDate对象,不具有expireds属性。

也许您只需要像这样定义的expired对象:

var expired = new ep.Plugin(c);

或者您可能需要ep对象而不是edend

说实话,我不知道图书馆,只是猜测。

as crawer -ninja-expired README说:'s ** work in progress **..

也,我已经阅读了源代码,没有expired()expired = {}这样的东西

所以基本上你什么也做不了