From 3567498e0a0dc922c355de5379fbf15d7a0d6e89 Mon Sep 17 00:00:00 2001 From: "xxx.Yan" Date: Wed, 7 Aug 2024 22:02:35 +0800 Subject: [PATCH] fix(route): people handle diff site encoding. (#16389) --- lib/routes/people/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/routes/people/index.ts b/lib/routes/people/index.ts index 0970a07c0..48c352385 100644 --- a/lib/routes/people/index.ts +++ b/lib/routes/people/index.ts @@ -32,7 +32,9 @@ async function handler(ctx) { responseType: 'buffer', }); - const $ = load(iconv.decode(response, 'gbk')); + const encoding = site === 'www' ? 'gbk' : 'utf-8'; + const decodedResponse = iconv.decode(response, encoding); + const $ = load(decodedResponse); $('em').remove(); $('.bshare-more, .page_n, .page').remove(); @@ -64,7 +66,7 @@ async function handler(ctx) { responseType: 'buffer', }); - const data = iconv.decode(detailResponse, 'gbk'); + const data = iconv.decode(detailResponse, encoding); const content = load(data); content('.paper_num, #rwb_tjyd').remove();