Node.js를 사용하여 다음 웹 페이지의 html 컨텐츠를 가져 오는 경우
eternagame.wikia.com/wiki/EteRNA_Dictionary
다음과 같은 오류가 발생합니다.
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 에서이 오류를 찾아 보았고 node.js가 DNS에서 서버를 찾을 수 없기 때문이라는 것을 깨달았습니다. 그러나 코드가 완벽하게 작동하기 때문에 왜 이것이 될지 잘 모르겠습니다 www.google.com.
내 코드는 다음과 같습니다 (호스트가 변경된 것을 제외하고는 매우 유사한 질문에서 실제로 복사하여 붙여 넣습니다).
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);
});
});
: 여기에 복사하여 붙여 넣을 소스 인 방법 Expressjs에서 웹 서비스 호출을하는가?
node.js와 함께 모듈을 사용하지 않습니다.
읽어 주셔서 감사합니다.
var http = require("http");하거나 var https = require("https");기반으로 해야 함
ENOTFOUND 뜻입니까?