From 6083f0f250b003a6fe4ce979dcd26af7a6e53dc3 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Fri, 23 Oct 2020 23:32:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BD=91=E6=98=93=20encoding=20issue=20?= =?UTF-8?q?(#5983)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/netease/news/rank.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/routes/netease/news/rank.js b/lib/routes/netease/news/rank.js index eb550dbf6..3dd47557d 100644 --- a/lib/routes/netease/news/rank.js +++ b/lib/routes/netease/news/rank.js @@ -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.