Quando si utilizza Node.js per provare a ottenere il contenuto html della seguente pagina Web:
eternagame.wikia.com/wiki/EteRNA_Dictionary
Ottengo il seguente errore:
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)
Ho già cercato questo errore su StackOverflow e mi sono reso conto che ciò è dovuto al fatto che node.js non riesce a trovare il server dal DNS (credo). Tuttavia, non sono sicuro del perché, dato che il mio codice funziona perfettamente www.google.com.
Ecco il mio codice (praticamente copiato e incollato da una domanda molto simile, tranne che con l'host modificato):
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);
});
});
Ecco la fonte da cui ho copiato e incollato: Come effettuare chiamate al servizio Web in Expressjs?
Non sto usando alcun modulo con node.js.
Grazie per aver letto.
var http = require("http");o var https = require("https");basato su host remoto
ENOTFOUND significa?