node.js 爬虫乱码问题 cheerio

 
使用如下两个库即可
const iconv = require('iconv-lite')
const request = require('request')

重点在于{url:"https://s.taobao.com/search?q=9787517054214",encoding:null}这段配置中
encoding必须存在,所以给个null即可,然后根据编码转换即可
iconv.decode(detail_body,'gbk');
request({url:"https://s.taobao.com/search?q=9787517054214",encoding:null},(error,res,body)={
const covertBody=iconv.decode(detail_body,'gbk');

}
最新回复(0)
/jishubrr_2BYXAfn4tAF7307ckQGsYoPm_2BY9LMBnRBpF1Nw9nI_3D4858686
8 简首页