我正在开发一个Web 爬网程序 ,但当我使用 superagent 获取页面时,阅读ECONNRESET 发生了。
const https = require('https');
https.globalAgent.options.secureProtocol = 'TLSv1_2_method';
const superagent = require('superagent-use')(require('superagent'))
superagent.use(require('superagent-verbose-errors'))
const cheerio = require('cheerio');
const baidu = "https://www.baidu.com/s?wd=";
const sogou = "https://www.sogou.com/web?query=";
function search(key) {
const fullUrl = baidu + key;
return superagent
.get(fullUrl)
.on('error', error => console.log(error))
.then(response => {
return parsehtml(response.body);
});
}
function parsehtml(htmlBody) {
}
module.exports=search;
以下是错误详细信息:
response:undefined
stack:"Error: read ECONNRESET\n at _errnoException (util.js:992:11)\n at
TLSWrap.onread (net.js:618:25)"
status:500
syscall:"read"
的安全性
如何解决此问题,非常感谢。