CNode

使用 cheerio 有没有出现过乱码的情况

Ssurgit发布于12 年前最后回复10 年前5 回复14555 浏览0 收藏

https://github.com/MatthewMueller/cheerio

有没有出现过中文乱码的。

 <meta name="keywords" content="&#x4E50;&#x8DA3;&#xFF01;!">

我自己用的时候会出现 一些中文 转为unicode

查看回复

回复 (5)

S
surgit#1·12 年前

主要是title 和 alt属性这些 会编程 unicode 编码,,求助。

J
JsonSong89#2·11 年前

var $ = cheerio.load(htmlStr, {decodeEntities: false});

X
XadillaX#3·11 年前

先转码吧。

true-html-escape 不谢:https://www.npmjs.com/package/true-html-escape

var escaper = require("true-html-escape");
 
escaper.escape("¤¥€");                                                  ///<= &curren;&yen;&euro; 
escaper.unescape("&lt;span&gt;&#29579;&#23612;&#29595;&lt;/span&gt;");  ///<= <span>王尼玛</span> 
escaper.unescape("&#12501;&#12521;&#12531;&#12489;&#12540;&#12523;");   ///<= フランドール 
escaper.unescape("(&#x256d;&#xffe3;3&#xffe3;)&#x256d;&#x2661;")         ///<= (╭ ̄3 ̄)╭♡ 
I
i5ting#4·11 年前

cheerio = Fast, flexible, and lean implementation of core jQuery designed specifically for the server.

有点意思

Y
yunkou#5·10 年前

@xadillax 谢谢

参与回复
登录后即可参与回复。登录