From f745d62c34e18f3fdf3a6294b337df6afc0a6589 Mon Sep 17 00:00:00 2001 From: Junxi Lu <52453543+shrugginG@users.noreply.github.com> Date: Tue, 1 Jul 2025 11:13:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E6=B7=BB=E5=8A=A0=E4=B8=9C?= =?UTF-8?q?=E5=8D=97=E5=A4=A7=E5=AD=A6=E7=BD=91=E7=BB=9C=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E5=AD=A6=E9=99=A2=E9=80=9A=E7=9F=A5=E5=85=AC?= =?UTF-8?q?=E5=91=8A=20(#19488)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/seu/cyber/index.ts | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 lib/routes/seu/cyber/index.ts diff --git a/lib/routes/seu/cyber/index.ts b/lib/routes/seu/cyber/index.ts new file mode 100644 index 000000000..43274f9c5 --- /dev/null +++ b/lib/routes/seu/cyber/index.ts @@ -0,0 +1,78 @@ +import { Route } from '@/types'; +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; + +export const route: Route = { + path: '/cyber/tzgg', + categories: ['university'], + example: '/seu/cyber/tzgg', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['cyber.seu.edu.cn/tzgg/list.htm', 'cyber.seu.edu.cn/'], + }, + ], + name: '网络空间安全学院 - 通知公告', + maintainers: ['shrugginG'], + handler, + description: '东南大学网络空间安全学院通知公告', +}; + +async function handler() { + const host = 'https://cyber.seu.edu.cn'; + const link = `${host}/tzgg/list.htm`; + + const { data: response } = await got(link); + const $ = load(response); + + const list = $('#wp_news_w6 ul.wp_article_list li.list_item') + .toArray() + .map((item) => { + const e = $(item); + const a = e.find('.Article_Title a'); + const title = a.text().trim(); + const href = a.attr('href'); + const dateText = e.find('.Article_PublishDate').text().trim(); + + return { + title, + link: new URL(href || '', host).href, + pubDate: parseDate(dateText), + description: '', + }; + }); + + const out = await Promise.all( + list.map((item) => + cache.tryGet(item.link, async () => { + try { + const response = await got(item.link); + const $ = load(response.data); + + item.description = $('.wp_articlecontent').html() || $('.article-content').html() || $('.main-text').html() || $('article').html() || ''; + + return item; + } catch { + return item; + } + }) + ) + ); + + return { + link, + title: '东南大学网络空间安全学院 - 通知公告', + description: '东南大学网络空间安全学院通知公告RSS', + item: out, + }; +}