首页 > 开发 > NodeJS > 正文

nodejs 用superagent抓取网页gbk编码乱码的问题

2017-09-08 17:25:58  来源:网友分享

网上找了太多了。什么比如iconv-lite什么的,都试过了。就是不行。

href = 'http://www.qq.com/';            console.log(href);            superagent.get(href).end(function (err, res) {                var str = res.text;                var buf = new Buffer(str);                str = iconv.decode(buf, 'GBK');                console.log(str);            });                  折腾了一夜了,可有解决方案?                                

解决方案