为了账号安全,请及时绑定邮箱和手机立即绑定

Node.js getaddrinfo ENOTFOUND

Node.js getaddrinfo ENOTFOUND

料青山看我应如是 2019-09-02 08:34:46
使用Node.js尝试获取以下网页的html内容时:eternagame.wikia.com/wiki/EteRNA_Dictionary我收到以下错误:events.js:72    throw er; // Unhandled 'error' event          ^Error: getaddrinfo ENOTFOUND    at errnoException (dns.js:37:11)    at Object.onanswer [as oncomplete] (dns.js:124:16)我确实已经在stackoverflow上查找了这个错误,并意识到这是因为node.js无法从DNS中找到服务器(我认为)。但是,我不确定为什么会这样,因为我的代码完美无缺www.google.com。这是我的代码(几乎从一个非常相似的问题复制和粘贴,除了更改主机):var http = require("http");var options = {    host: 'eternagame.wikia.com/wiki/EteRNA_Dictionary'};http.get(options, function (http_res) {    // initialize the container for our data    var data = "";    // this event fires many times, each time collecting another piece of the response    http_res.on("data", function (chunk) {        // append this chunk to our growing `data` var        data += chunk;    });    // this event fires *one* time, after all the `data` events/chunks have been gathered    http_res.on("end", function () {        // you can use res.send instead of console.log to output via express        console.log(data);    });});以下是我复制和粘贴的来源:如何在Expressjs中进行Web服务调用?我没有使用node.js的任何模块。谢谢阅读。
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 1736 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信