{Nodejs} request URL 中文乱码

  1 var cheerio = require("cheerio");
  2 var request = require('request');
  3 var iconv = require('iconv-lite');
  4 
  5 request.get({url:'http://mil.news.sina.com.cn/2015-07-21/1454835521.html',encoding:null},function(error,response,body){
  6     var  html  = iconv.decode(body, 'gb2312');
  7     console.log(html);
  8     $ = cheerio.load(body,{decodeEntities: false});
  9 //  console.log($("#artibody").html());
 10 
 11 
 12 });

 

posted @ 2015-07-21 16:05  三个安目  阅读(5765)  评论(0编辑  收藏  举报