爬虫中文乱码可做如下处理
import request from 'superagent'; import cheerio from 'cheerio';//类似jquery写法 const Iconv = require('iconv').Iconv; const iconv = new Iconv('GBK', 'UTF-8'); request.get(url) .end(async(err, res) => { const result = iconv.convert(new Buffer(body, 'binary')).toString(); const $ = cheerio.load(result);
//... })