From 7ea65c2509d7c5b5ff27d35181d0813cb2f7f0cd Mon Sep 17 00:00:00 2001 From: Keo Date: Wed, 4 Sep 2024 22:08:13 +0800 Subject: [PATCH] fix(route): tidy sis001 articles (#16619) --- lib/routes/sis001/author.ts | 2 +- lib/routes/sis001/common.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/routes/sis001/author.ts b/lib/routes/sis001/author.ts index 51fb8b031..d724a0570 100644 --- a/lib/routes/sis001/author.ts +++ b/lib/routes/sis001/author.ts @@ -29,7 +29,7 @@ async function handler(ctx) { const response = await got(url); const $ = load(response.data); - const username = $('div.username').text(); + const username = $('div.bg div.title').text().replace('的个人空间', ''); let items = $('div.center_subject ul li a[href^=thread]') .toArray() diff --git a/lib/routes/sis001/common.ts b/lib/routes/sis001/common.ts index 51632562b..4e3e485a5 100644 --- a/lib/routes/sis001/common.ts +++ b/lib/routes/sis001/common.ts @@ -22,8 +22,15 @@ async function getThread(item) { ), 8 ); - $('div[id^=postmessage_] table, fieldset, .posttags, strong').remove(); - item.description = $('div[id^=postmessage_]').eq(0).remove('strong').html() + ($('.defaultpost .postattachlist').html() ?? ''); + $('div[id^=postmessage_] table, fieldset, .posttags, strong font').remove(); + item.description = + $('div[id^=postmessage_]') + .eq(0) + .html() + ?.replaceAll('\n', '') + .replaceAll(/\u3000{2}.+?(((?:
){2})|( ))/g, (str) => `

${str.replaceAll('
', '')}

`) + .replaceAll(' ', '') + .replace(/^.+?((?:作者)|(?:

))/, '$1') + ($('.defaultpost .postattachlist').html() ?? ''); return item; }