1

I am developing a Web crawl program for fun, but when i use superagent to get page, read ECONNRESET occurred.

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;

The following is error details:

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"

and security about https://www.baidu.com

Security in Chrome

How can fix this issue, thanks a lot.

0 Answers0