NodeJS, a small reptile, has a problem of garbled code.

  node.js, question

The code of the target site is GBK. When crawling with NodeJS, use

console.log(body);

Is there any code disorder?

There is also cheerio that I used to parse HTML and then print:

console.log($('body').html());

After the Chinese became:

��������

I’ve tried my best, but I can’t find a good solution. Perhaps my description is not accurate enough.

I suggest you read my articlehttp://www.cnblogs.com/zichi/p/5157887.htmlAndhttp://www.cnblogs.com/zichi/p/5135636.html

99% can solve your problem