Cuando utilice Node.js para intentar obtener el contenido html de la siguiente página web:
eternagame.wikia.com/wiki/EteRNA_Dictionary
Obtuve el siguiente error:
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)
Ya busqué este error en stackoverflow, y me di cuenta de que esto se debe a que node.js no puede encontrar el servidor desde DNS (creo). Sin embargo, no estoy seguro de por qué sería así, ya que mi código funciona perfectamente www.google.com.
Aquí está mi código (prácticamente copiado y pegado de una pregunta muy similar, excepto con el host cambiado):
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);
});
});
Aquí está la fuente desde donde copié y pegué: ¿Cómo hacer llamadas de servicio web en Expressjs?
No estoy usando ningún módulo con node.js.
Gracias por leer.
var http = require("http");o var https = require("https");basado en host remoto
ENOTFOUND significa