使用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 回答
- 0 關注
- 1795 瀏覽
添加回答
舉報
0/150
提交
取消