fix: 网易 encoding issue (#5983)

This commit is contained in:
Laam Pui 2020-10-23 23:32:53 +08:00 committed by GitHub
parent 97b12d11e0
commit 6083f0f250
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

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.