From fd5cc6868fe40da90fca63954e8ca227b023fa16 Mon Sep 17 00:00:00 2001 From: "F.Rushmore.Coglan" <61170850+Fgju@users.noreply.github.com> Date: Tue, 1 Apr 2025 18:28:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=B8=AD=E5=9B=BD?= =?UTF-8?q?=E6=94=BF=E6=B3=95=E5=A4=A7=E5=AD=A6=20(#18748)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): 添加中国政法大学教务处通知公告路由 * fix(route): 修改中国政法大学教务处路由名称为“教务处通知公告” --- lib/routes/cupl/jwc.ts | 69 ++++++++++++++++++++++++++++++++++++ lib/routes/cupl/namespace.ts | 20 +++++++++++ 2 files changed, 89 insertions(+) create mode 100644 lib/routes/cupl/jwc.ts create mode 100644 lib/routes/cupl/namespace.ts diff --git a/lib/routes/cupl/jwc.ts b/lib/routes/cupl/jwc.ts new file mode 100644 index 000000000..45dc33cb9 --- /dev/null +++ b/lib/routes/cupl/jwc.ts @@ -0,0 +1,69 @@ +import { Route } from '@/types'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; +import ofetch from '@/utils/ofetch'; +// import cache from '@/utils/cache'; + +export const route: Route = { + path: '/jwc', + url: 'jwc.cupl.edu.cn/index/tzgg.htm', + categories: ['university'], + example: '/cupl/jwc', + description: '中国政法大学教务处通知公告', + name: '教务处通知公告', + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['jwc.cupl.edu.cn/index/tzgg.htm', 'jwc.cupl.edu.cn/'], + target: '/jwc', + }, + ], + maintainers: ['Fgju'], + handler: async (/* ctx*/) => { + const host = 'https://jwc.cupl.edu.cn/'; + const response = await ofetch(host + 'index/tzgg.htm'); + const $ = load(response); + + const list = $('li[id^=line_u8_]') + .toArray() + .map((elem) => { + const elem_ = $(elem); + const a = elem_.find('a'); + return { + link: a[1].attribs.href, + title: $(a[1]).text(), + pubDate: parseDate(elem_.find('span').text(), 'YYYY-MM-DD'), + category: $(a[0]).text().slice(0, -1), + description: '', + }; + }); + /* + const items = await Promise.all( + list.map((item) => { + cache.tryGet(item.link, async () => { + const response = await ofetch(host + item.link.slice(3)); + const $ = load(response); + const content = $('.form[name=_newscontent_fromname]').html(); + item.description = content ?? ''; + return item; + } + ) + }) + ); + */ + return { + title: '通知公告', + link: 'https://jwc.cupl.edu.cn/index/tzgg.htm', + description: '中国政法大学教务处通知公告', + language: 'zh-CN', + item: list, + }; + }, +}; diff --git a/lib/routes/cupl/namespace.ts b/lib/routes/cupl/namespace.ts new file mode 100644 index 000000000..be4aa27fb --- /dev/null +++ b/lib/routes/cupl/namespace.ts @@ -0,0 +1,20 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'CUPL', + url: 'jwc.cupl.edu.cn/index/tzgg.htm', + description: 'China University of Political Science and Law Academic Affairs Office Notices', + + zh: { + name: '中国政法大学', + description: '中国政法大学教务处通知公告', + }, + 'zh-TW': { + name: '中國政法大學', + description: '中國政法大學教務處通知公告', + }, + ja: { + name: '中国政法大学', + description: '中国政法大学教務処通知公告', + }, +};