Precautions:
1, the request module The Chinese code flaw: uses the Requset to obtain the Chinese HTML, must set the encoding to be null, then uses the Iconv or the Iconv-lite transcoding, otherwise will appear garbled
request ({ url: feed, timeout: 100000, poll: false, encoding: null }, function (err, res, body) { if (!err & & RES.STATUSCODE == 200) { &nbsP; var bodydecode = iconvlite.decode (body, ' utf-8 '), $ = cheerio.load (Bodydecode, {decodeentities: false}) } });
2, cheerio module loading Chinese HTML will automatically decode the Chinese as Unicode, Chinese are all escaped into & #xNNNN, a big pit. Use load (HTML) to set the
var $ = cheerio.load (bodyencoding, {decodeentities:false});
Temporarily encountered two more difficult problems, I hope the great God guidance.
RELATED Links: https://github.com/yeoman/generator/issues/638
This article is from the "ZXXXJ Technology blog" blog, make sure to keep this source http://zxxxj.blog.51cto.com/6485028/1567290
Notes on using Nodejs to capture RSS data and RSS text