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: '中国政法大学教務処通知公告', + }, +};