【问题标题】:Node js Application cannot call method of undefinedNode js应用程序无法调用未定义的方法
【发布时间】:2015-09-25 11:00:08
【问题描述】:

我使用在 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/"});
}

【问题讨论】:

  • 为什么是 -1 ?我试图正确地构造问题和代码。至少当你 -1 解释原因时..

标签: javascript node.js web-crawler


【解决方案1】:

end 是一个 Date 对象,它没有 expireds 属性。

也许您只需要定义如下的expired 对象:

var expired = new ep.Plugin(c);

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

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

【讨论】:

  • 也许我没有正确纠正我的第一个错误,毕竟 ed 很好。但后来我遇到了错误:ReferenceError: ed is not defined
  • 当他们给你一个错误的例子开始时总是很好,非常感谢你的帮助。
  • 谢谢,我再看看。也感谢您花时间和精力阅读和回答。
【解决方案2】:

正如crawler-ninja-expired README 所说:这是**正在进行的工作**..

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

所以基本上你无能为力:(

【讨论】:

    猜你喜欢
    • 2013-11-10
    • 2013-07-08
    • 2014-05-28
    • 1970-01-01
    • 2019-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-25
    相关资源
    最近更新 更多