阅读 27

node 实现数据爬虫

const originRequest = require("request");
const cheerio = require("cheerio");
const iconv = require("iconv-lite");

function request(url, callback) {
    const options = {
        // url: url,
        encoding: null
    };
    originRequest(url, options, callback);
}

for (let i = 103234; i < 103238; i++) {
    const url = `https://www.dy2018.com/i/${i}.html`;
    request(url, function (err, res, body) {
        console.log("body",body,err) //这里err为 unable to verify the first certificate 有可能出现 待处理
        // const html = iconv.decode(body, "gb2312");
        // const $ = cheerio.load(html);
        // console.log($(".title_all h1").text());
    });
}

//unable to verify the first certificate 有可能出现 待处理
复制代码
文章分类
阅读
文章标签