使用Node.js嘗試獲取以下網(wǎng)頁(yè)的html內(nèi)容時(shí):eternagame.wikia.com/wiki/EteRNA_Dictionary我收到以下錯(cuò)誤: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)我確實(shí)已經(jīng)在stackoverflow上查找了這個(gè)錯(cuò)誤,并意識(shí)到這是因?yàn)閚ode.js無(wú)法從DNS中找到服務(wù)器(我認(rèn)為)。但是,我不確定為什么會(huì)這樣,因?yàn)槲业拇a完美無(wú)缺www.google.com。這是我的代碼(幾乎從一個(gè)非常相似的問(wèn)題復(fù)制和粘貼,除了更改主機(jī)):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); });});以下是我復(fù)制和粘貼的來(lái)源:如何在Expressjs中進(jìn)行Web服務(wù)調(diào)用?我沒(méi)有使用node.js的任何模塊。謝謝閱讀。
Node.js getaddrinfo ENOTFOUND
料青山看我應(yīng)如是
2019-09-02 08:34:46