HTML实体编码转换为字符(JavaScript)
一般方法:
function entityToString(entity) {
var div = document.createElement(‘div‘);
div.innerHTML = entity;
var res = div.innerText || div.textContent;
return res;
}
在不支持原生dom的情况下(cheerio下的方法):
function entityToString(entity) {
$(‘#ets‘).remove();
$(‘body‘).append(‘<div id="ets"></div>‘);
$(‘#ets‘).html(entity);
var res = $(‘#ets‘).text();
return res;
}
原文:https://www.cnblogs.com/kujisa/p/13667040.html