diff --git a/lib/routes/chnmuseum/namespace.ts b/lib/routes/chnmuseum/namespace.ts new file mode 100644 index 0000000000..518262b18e --- /dev/null +++ b/lib/routes/chnmuseum/namespace.ts @@ -0,0 +1,10 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'National Museum Of China', + url: 'www.chnmuseum.cn', + description: '中国国家博物馆(National Museum of China)位于北京市中心天安门广场东侧,东长安街南侧,与人民大会堂东西相对称,是一座系统展示中华民族文化历史的综合性博物馆,也是世界上最大的博物馆之一。', + zh: { + name: '中国国家博物馆', + }, +}; diff --git a/lib/routes/chnmuseum/xingnew.ts b/lib/routes/chnmuseum/xingnew.ts new file mode 100644 index 0000000000..a0d7f1480f --- /dev/null +++ b/lib/routes/chnmuseum/xingnew.ts @@ -0,0 +1,74 @@ +import { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; +import cache from '@/utils/cache'; +import timezone from '@/utils/timezone'; + +export const route: Route = { + path: '/zx/xingnew', + categories: ['travel'], + example: '/zx/xingnew', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['chnmuseum.cn/zx/xingnew'], + target: '/zx/xingnew', + }, + ], + name: '资讯要闻', + maintainers: ['ShabbyWhineYear'], + handler: async () => { + + const response = await ofetch('https://www.chnmuseum.cn/zx/xingnew/'); + const $ = load(response); + + const list = $('ul.cj_xushuliebao_list li') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('a'); + const dateText = item.find('span.date').text(); + + return { + title: a.attr('title') || a.text(), + link: new URL(a.attr('href'), 'https://www.chnmuseum.cn/zx/xingnew/').href, + pubDate: timezone(parseDate(dateText, 'YYYY/MM/DD'), +8), + // description: a.attr('title') || a.text(), + }; + }); + + const items = await Promise.all( + list.map((item) => + cache.tryGet(item.link, async () => { + const response = await ofetch(item.link); + const $ = load(response); + + // 选择类名为“comment-body”的第一个元素 + item.description = $('.cj_xw_cong').first().html(); + + // 上面每个列表项的每个属性都在此重用, + // 并增加了一个新属性“description” + return item; + }) + ) + ); + + return { + // 源标题 + title: '中国国家博物馆资讯要闻', + // 源链接 + link: 'https://www.chnmuseum.cn/zx/xingnew/', + // 源文章 + item: items, + }; + }, +}; diff --git a/lib/routes/chnmuseum/xwzt.ts b/lib/routes/chnmuseum/xwzt.ts new file mode 100644 index 0000000000..a83f99f488 --- /dev/null +++ b/lib/routes/chnmuseum/xwzt.ts @@ -0,0 +1,68 @@ +import { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; +import { load } from 'cheerio'; + +export const route: Route = { + path: '/zx/xwzt', + categories: ['travel'], + example: '/zx/xwzt', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['chnmuseum.cn/zx/xwzt'], + target: '/zx/xwzt', + }, + ], + name: '资讯专题', + maintainers: ['ShabbyWhineYear'], + handler: async () => { + + const response = await ofetch('https://www.chnmuseum.cn/zx/xwzt/'); + const $ = load(response); + + const items = $('ul.cj_hd_zhanh li') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('div.cj_hd_biaoti a').first(); + + return { + title: a.attr('title') || a.text(), + link: new URL(a.attr('href'), 'https://www.chnmuseum.cn').href, + }; + }); + + // const items = await Promise.all( + // list.map((item) => + // cache.tryGet(item.link, async () => { + // const response = await ofetch(item.link); + // const $ = load(response); + // + // // 选择类名为“comment-body”的第一个元素 + // item.description = $('.cj_xw_cong').first().html(); + // + // // 上面每个列表项的每个属性都在此重用, + // // 并增加了一个新属性“description” + // return item; + // }) + // ) + // ); + + return { + // 源标题 + title: '中国国家博物馆资讯专题', + // 源链接 + link: 'https://www.chnmuseum.cn/zx/xwzt/', + // 源文章 + item: items, + }; + }, +};