Ao usar o Node.js para tentar obter o conteúdo html da seguinte página da web:
eternagame.wikia.com/wiki/EteRNA_Dictionary
Estou tendo o erro a seguir:
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)
Eu já procurei esse erro no stackoverflow e percebi que isso ocorre porque o node.js não consegue encontrar o servidor pelo DNS (acho). No entanto, não sei por que isso seria, pois meu código funciona perfeitamente www.google.com.
Aqui está o meu código (praticamente copiado e colado de uma pergunta muito semelhante, exceto com o host alterado):
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);
});
});
Aqui está a fonte de onde eu copiei e colei: Como fazer chamadas de serviço da Web no Expressjs?
Eu não estou usando nenhum módulo com node.js.
Obrigado pela leitura.
var http = require("http");ou var https = require("https");baseado em host remoto
ENOTFOUND significa