我已经使用昨天工作的模块cheerio、request 和longjohn 编写了一些代码,但今天它总是抛出“ECONNREFUSED”错误。
我尝试使用使用请求的简单示例代码:
var request = require('request');
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Show the HTML for the Google homepage.
}
else{
console.log(error);
}
})
然而它仍然返回:
{[Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
只是想知道这可能是什么原因,我可以使用网络浏览器很好地连接到互联网。
谢谢