From f7f73e8961ceb39018401b9e90b8ce7fe790f46d Mon Sep 17 00:00:00 2001 From: Skylwn Date: Thu, 9 Jan 2025 22:15:25 +0800 Subject: [PATCH] feat(route): add route for university: CTBU XXGG (#18082) * feat(route): add route for university: CTBU XXGS * update filename --- lib/routes/ctbu/namespace.ts | 7 +++++ lib/routes/ctbu/xxgg.ts | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 lib/routes/ctbu/namespace.ts create mode 100644 lib/routes/ctbu/xxgg.ts diff --git a/lib/routes/ctbu/namespace.ts b/lib/routes/ctbu/namespace.ts new file mode 100644 index 00000000000000..f0e5557592afc3 --- /dev/null +++ b/lib/routes/ctbu/namespace.ts @@ -0,0 +1,7 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '重庆工商大学', + url: 'www.ctbu.edu.cn/', + lang: 'zh-CN', +}; diff --git a/lib/routes/ctbu/xxgg.ts b/lib/routes/ctbu/xxgg.ts new file mode 100644 index 00000000000000..c651f29eed37f1 --- /dev/null +++ b/lib/routes/ctbu/xxgg.ts @@ -0,0 +1,50 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; +const baseURL = 'https://www.ctbu.edu.cn/index/xxgg.htm'; + +export const route: Route = { + path: '/xxgg', + categories: ['university'], + example: '/ctbu/xxgg', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['www.ctbu.edu.cn/', 'www.ctbu.edu.cn/index/xxgg.htm'], + }, + ], + name: '学校公告', + maintainers: ['Skylwn'], + handler, + url: 'www.ctbu.edu.cn/', +}; + +async function handler() { + const response = await got(baseURL); + const $ = load(response.data); + const items = $('li.clearfix') + .toArray() + .map((item) => { + item = $(item); + return { + title: item.find('a').attr('title'), + description: item.find('p').text(), + pubDate: parseDate(item.find('h6').text() + '-' + item.find('em').text(), 'YYYY-MM-DD'), + link: item.find('a').attr('href'), + }; + }); + return { + title: $('title').text(), + link: baseURL, + item: items, + }; +}