贴代码: var request = require(‘superagent’); var iconv = require(‘iconv-lite’); var url = “http://opinion.people.com.cn/n1/2016/1116/c1003-28873412.html”; request .get(url) .end(function(err, res){ var text = iconv.decode(new Buffer(res.text), ‘GB2312’) console.log(text) });
网页编码是gb2312的,不知道为什么输出的网页经过转码后,字符全是锟斤拷台锟斤拷锟斤拷应锟斤拷台锟斤拷锟斤拷锟节碉拷锟叫癸拷锟斤拷锟斤拷锟斤拷锟斤拷同锟