Aşağıdaki web sayfasının html içeriğini denemek ve almak için Node.js'yi kullanırken:
eternagame.wikia.com/wiki/EteRNA_Dictionary
Aşağıdaki hatayı alıyorum:
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 zaten bu hatayı aradım ve bunun nedeni node.js DNS sunucu bulamıyor çünkü (fark). Ancak, benim kod mükemmel çalışır gibi bu neden olur emin değilim www.google.com.
İşte benim kod (neredeyse değişti ve çok benzer bir sorudan yapıştırılan, ana bilgisayar değişti hariç):
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);
});
});
Kopyaladığım ve yapıştırdığım kaynak: Expressjs'de web hizmeti çağrıları nasıl yapılır?
Node.js ile herhangi bir modül kullanmıyorum.
Okuduğunuz için teşekkürler.
var http = require("http");ya davar https = require("https"); uzak ana bilgisayara bağlı
ENOTFOUND demek