fix(route): people handle diff site encoding. (#16389)

This commit is contained in:
xxx.Yan 2024-08-07 22:02:35 +08:00 committed by GitHub
parent 5595222a26
commit 3567498e0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -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();