diff --git a/lib/routes/hpoi/banner-item.ts b/lib/routes/hpoi/banner-item.ts
index 8643fce5c..0382bb119 100644
--- a/lib/routes/hpoi/banner-item.ts
+++ b/lib/routes/hpoi/banner-item.ts
@@ -1,4 +1,5 @@
import { Route } from '@/types';
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -33,19 +34,35 @@ async function handler() {
url: link,
});
const $ = load(response.data);
+
+ const items = await Promise.all(
+ $('#content .item')
+ .toArray()
+ .map(async (_item) => {
+ const $item = $(_item);
+ const link = new URL($item.find('a').attr('href') ?? '', 'https://www.hpoi.net').href;
+ if (!link.startsWith('https://www.hpoi.net')) {
+ return;
+ }
+ return await cache.tryGet(link, async () => {
+ const detailResponse = await got(link);
+ const $$ = load(detailResponse.data);
+ $$('.hpoi-album-content .album-ibox').remove();
+ $$('.hpoi-album-content .row').remove();
+ $$('.hpoi-album-content .hpoi-hr-line').remove();
+ return {
+ title: $item.find('.title').text(),
+ link,
+ description: $$('.hpoi-album-content').html() || `
`,
+ pubDate: new Date($item.find('.time').text().replace('发布时间:', '')).toUTCString(),
+ };
+ });
+ })
+ );
+
return {
title: `Hpoi 手办维基 - 热门推荐`,
link,
- item: $('#content .item')
- .toArray()
- .map((_item) => {
- _item = $(_item);
- return {
- title: _item.find('.title').text(),
- link: 'https://www.hpoi.net/' + _item.find('a').attr('href'),
- description: `
`,
- pubDate: new Date(_item.find('.time').text().replace('发布时间:', '')).toUTCString(),
- };
- }),
+ item: items.filter((item) => !!item),
};
}