From e80dde7ff864c67474186506c10bfb7907aa4cbc Mon Sep 17 00:00:00 2001 From: GhhG123 <100225935+GhhG123@users.noreply.github.com> Date: Wed, 20 Aug 2025 22:48:09 +0800 Subject: [PATCH] feat(route): add shu global and xxgk routes (#19875) * feat(route): add shu global and xxgk routes * Update xxgk.ts --- lib/routes/shu/global.ts | 11 ++-- lib/routes/shu/xxgk.ts | 107 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 lib/routes/shu/xxgk.ts diff --git a/lib/routes/shu/global.ts b/lib/routes/shu/global.ts index 553df6619..f1e255a18 100644 --- a/lib/routes/shu/global.ts +++ b/lib/routes/shu/global.ts @@ -6,7 +6,8 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; const noticeType = { - tzgg: { title: '上海大学国际部港澳台-通知公告', url: 'https://global.shu.edu.cn/cd/tzgg/3.htm' }, + tzgg: { title: '上海大学国际部港澳台-通知公告', url: 'https://global.shu.edu.cn/cd/tzgg.htm' }, + xwsd: { title: '上海大学国际部港澳台-新闻速递', url: 'https://global.shu.edu.cn/cd/xwsd.htm' }, }; export const route: Route = { @@ -24,7 +25,7 @@ export const route: Route = { }, radar: [ { - source: ['global.shu.edu.cn/'], + source: ['global.shu.edu.cn/cd/tzgg.htm', 'global.shu.edu.cn/cd/xwsd.htm'], target: '/global', }, ], @@ -32,9 +33,9 @@ export const route: Route = { maintainers: ['GhhG123'], handler, url: 'global.shu.edu.cn/', - description: `| 通知公告 | -| -------- | -| tzgg |`, + description: `| 通知公告 | 新闻速递 | +| -------- | -------- | +| tzgg | xwsd |`, }; async function handler(ctx) { diff --git a/lib/routes/shu/xxgk.ts b/lib/routes/shu/xxgk.ts new file mode 100644 index 000000000..e2ab63dec --- /dev/null +++ b/lib/routes/shu/xxgk.ts @@ -0,0 +1,107 @@ +import { Route } from '@/types'; +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; +import timezone from '@/utils/timezone'; + +const noticeType = { + dwjlxm: { title: '上海大学信息公开网-信息公开栏目-国际合作与交流-对外交流项目', url: 'https://xxgk.shu.edu.cn/xxgklm/gjhzyjl1/dwjlxm.htm' }, // 对外交流项目 + hzjl: { title: '上海大学信息公开网-信息公开栏目-国际合作与交流-合作交流', url: 'https://xxgk.shu.edu.cn/xxgklm/gjhzyjl1/hzjl.htm' }, // 合作交流 +}; + +export const route: Route = { + path: '/xxgk/:type?', + categories: ['university'], + example: '/shu/xxgk/dwjlxm', + parameters: { type: '分类,默认为对外交流项目' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['xxgk.shu.edu.cn/'], + target: '/xxgk', + }, + ], + name: '信息公开网', + maintainers: ['GhhG123'], + handler, + url: 'xxgk.shu.edu.cn/', + description: `| 对外交流项目 | 合作交流 | +| -------- | --------- | +| dwjlxm | hzjl |`, +}; + +async function handler(ctx) { + const type = ctx.req.param('type') ?? 'dwjlxm'; + const rootUrl = 'https://xxgk.shu.edu.cn'; + + // 发起 HTTP GET 请求 + const response = await got({ + method: 'get', + + /* headers: { + 'user-agent': UA, + cookie: await getCookie(ctx), + }, */ + url: noticeType[type].url, + }); + + const $ = load(response.data); + + const list = $('li[id^="line_u6_"]') // 定位到每个包含新闻的