Node.js adresi kullanılır ENOTFOUND
Node.js deneyin ve aşağıdaki web sayfası: html içeriği almak için 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)
Zaten stackoverflow bu hata aramak yaptım, ve bu node.js olamaz DNS (sanırım) server bulmak olduğunu fark etti. Ancak, bu benim mükemmel bir kod www.google.com
çalışır gibi olurdu neden emin değilim.
İşte benim kod (neredeyse kopyalanan ve ana değişti dışında çok benzer bir soru yapıştırdığınız):
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);
});
});
Ben burada kopyalanan ve yapıştırılan kaynağı nerede : How to make web service calls in Expressjs?
Node.js herhangi bir modül kullanıyorum.
Okuduğunuz için teşekkürler
Vineet
CEVAP
Node.jsHTTP
modülü belgelerine bakın: http://nodejs.org/api/http.html#http_http_request_options_callback
http.get('http://eternagame.wikia.com/wiki/EteRNA_Dictionary', callback)
URL url.parse()
; ile ayrıştırılır arayın veya options
nerede http.get(options, callback)
, Ara
{
host: 'eternagame.wikia.com',
path: '/wiki/EteRNA_Dictionary'
}
Nasıl node.js Kripto HMAC-SHA1 hash ol...
Nasıl node.exe birlikte etmesinin önün...
, Node.js JavaScript: Dizi.dosyalarda ...
Nasıl ve kabuk boolean değişkenleri bi...
Eğer yolu dosya veya dizin olup olmadı...