fix: 网易 encoding issue (#5983)

This commit is contained in:
Laam Pui
2020-10-23 16:32:53 +01:00
committed by GitHub
parent 97b12d11e0
commit 6083f0f250
+9 -6
View File
@@ -115,12 +115,15 @@ module.exports = async (ctx) => {
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
try {
const res = await got({
method: 'get',
url: item.link,
responseType: 'buffer',
});
const content = cheerio.load(iconv.decode(res.data, 'gbk'));
let res;
let content;
if (item.link.startsWith('https://ent.163.com')) {
res = await got({ method: 'get', url: item.link, responseType: 'buffer' });
content = cheerio.load(iconv.decode(res.data, 'gbk'));
} else {
res = await got.get(item.link);
content = cheerio.load(res.data);
}
if (content('#ne_wrap').attr('data-publishtime')) {
// To get pubDate from most pages.