nodejs:读取ECONNRESET

时间:2018-07-10 03:20:18

标签: node.js https superagent

我正在开发一个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"

和有关https://www.baidu.com

的安全性

Security in Chrome

如何解决此问题,非常感谢。

0 个答案:

没有答案