Notes on using Nodejs to capture RSS data and RSS text

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.