我正在提出以下请求:
var request = require('request');
var cheerio = require('cheerio');
request(url, function(error, response, html) {
if (!error) {
var $ = cheerio.load(html);
console.log(html);
}
我只得到jewel characters。 如何获得正确的输出?
我遵循了answer的建议。
app.get('/fetchdata', function(req, res) {
request({
uri: urlSource,
//null for encoding to avoid default utf-8
encoding: null
}, function(error, response, html) {
//using iconv to decode to iso-8859 /latin1
html = iconv.decode(html, 'iso-8859-1');
console.log(html);
...