From aae92ab9c06605cb32f0ecf36b5269df197552a0 Mon Sep 17 00:00:00 2001 From: shiquda <104683621+shiquda@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:35:42 +0800 Subject: [PATCH] feat(route): tongji/bks (#14558) * feat(route): tongji/bks * chore: format corrections * Update lib/v2/tongji/radar.js --------- --- lib/v2/tongji/bks.js | 31 ++++++++++++++++++++++++++++++ lib/v2/tongji/maintainer.js | 2 ++ lib/v2/tongji/radar.js | 8 ++++++++ lib/v2/tongji/router.js | 1 + website/docs/routes/university.mdx | 4 ++++ 5 files changed, 46 insertions(+) create mode 100644 lib/v2/tongji/bks.js diff --git a/lib/v2/tongji/bks.js b/lib/v2/tongji/bks.js new file mode 100644 index 000000000..41275b81b --- /dev/null +++ b/lib/v2/tongji/bks.js @@ -0,0 +1,31 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const link = 'https://bksy.tongji.edu.cn/30359/list.htm'; + const response = await got(link); + const $ = cheerio.load(response.data); + const list = $('.wcts-a0018 li'); + + ctx.state.data = { + title: '同济大学本科生院', + link, + description: '同济大学本科生院通知公告', + item: + list?.toArray().map((item) => { + item = $(item); + const a = item.find('a'); + const dateItem = item.find('.li-data'); + const yearAndMonth = dateItem.find('span').text().split('-'); + const day = dateItem.find('p').text(); + const date = `${yearAndMonth[0]}-${yearAndMonth[1]}-${day}`; + return { + title: item.find('.li-tt-title').text(), + description: item.find('.intro').text(), + link: new URL(a.attr('href'), link).href, + pubDate: parseDate(date, 'YYYY-MM-DD') + }; + }), + }; +}; diff --git a/lib/v2/tongji/maintainer.js b/lib/v2/tongji/maintainer.js index 9a4395cf7..d6d7d9aba 100644 --- a/lib/v2/tongji/maintainer.js +++ b/lib/v2/tongji/maintainer.js @@ -1,4 +1,6 @@ module.exports = { + '/bks': ['shiquda'], '/sse/:type?': ['sgqy'], '/yjs': ['shengmaosu'], + }; diff --git a/lib/v2/tongji/radar.js b/lib/v2/tongji/radar.js index 5d8d059cc..acb199288 100644 --- a/lib/v2/tongji/radar.js +++ b/lib/v2/tongji/radar.js @@ -1,6 +1,14 @@ module.exports = { 'tongji.edu.cn': { _name: '同济大学', + bksy: [ + { + title: '本科生院通知公告', + docs: 'https://docs.rsshub.app/routes/university#tong-ji-da-xue', + source: ['/'], + target: '/tongji/bks', + } + ], sse: [ { title: '软件学院通知', diff --git a/lib/v2/tongji/router.js b/lib/v2/tongji/router.js index baa0e4b72..5df80ae8f 100644 --- a/lib/v2/tongji/router.js +++ b/lib/v2/tongji/router.js @@ -1,4 +1,5 @@ module.exports = (router) => { + router.get('/bks', require('./bks')); router.get('/sse/:type?', require('./sse/notice')); router.get('/yjs', require('./yjs')); }; diff --git a/website/docs/routes/university.mdx b/website/docs/routes/university.mdx index 239f5e13e..5c1bd95be 100644 --- a/website/docs/routes/university.mdx +++ b/website/docs/routes/university.mdx @@ -2755,6 +2755,10 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE\_TL 注意: `qttz` 与 `xytz` 在原网站等价. +### 本科生院通知公告 {#tong-ji-da-xue-yan-jiu-sheng-yuan-tong-zhi-gong-gao} + + + ## 潍坊学院 {#wei-fang-xue-yuan} ### 新闻 {#wei-fang-xue-yuan-xin-wen}