{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 });

 

你可能感兴趣的:(request)