From 5d5f63dcec5598c07b4d63a57852fc19673c8d10 Mon Sep 17 00:00:00 2001 From: Ermaotie <63703577+Ermaotie@users.noreply.github.com> Date: Sun, 17 Sep 2023 01:20:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E5=8D=8E=E5=8D=97=E7=90=86?= =?UTF-8?q?=E5=B7=A5=E5=A4=A7=E5=AD=A6=20-=20=E6=9C=BA=E6=A2=B0=E4=B8=8E?= =?UTF-8?q?=E6=B1=BD=E8=BD=A6=E5=B7=A5=E7=A8=8B=E5=AD=A6=E9=99=A2=20(#1331?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add route of SCUT SMAE * resolve 'Route' in md --- lib/v2/scut/maintainer.js | 1 + lib/v2/scut/radar.js | 34 +++++++++++++++++++ lib/v2/scut/router.js | 1 + lib/v2/scut/smae/notice.js | 54 +++++++++++++++++++++++++++++++ website/docs/routes/university.md | 10 ++++++ 5 files changed, 100 insertions(+) create mode 100644 lib/v2/scut/smae/notice.js diff --git a/lib/v2/scut/maintainer.js b/lib/v2/scut/maintainer.js index b66d98b34..6c307266b 100644 --- a/lib/v2/scut/maintainer.js +++ b/lib/v2/scut/maintainer.js @@ -4,5 +4,6 @@ module.exports = { '/jwc/school/:category?': ['imkero', 'Rongronggg9'], '/scet/notice': ['railzy'], '/seie/news_center': ['auto-bot-ty'], + '/smae/:category?': ['Ermaotie'], '/yjs': ['shengmaosu'], }; diff --git a/lib/v2/scut/radar.js b/lib/v2/scut/radar.js index 0a52c3287..25a65f18b 100644 --- a/lib/v2/scut/radar.js +++ b/lib/v2/scut/radar.js @@ -22,6 +22,40 @@ module.exports = { source: ['/ee/16285/list.htm'], target: '/scut/seie/news_center', }, + { + title: '机械与汽车工程学院 - 通知公告', + docs: 'https://docs.rsshub.app/routes/university#hua-nan-li-gong-da-xue', + source: ['/smae/:category/list.htm'], + target: (params) => { + let tid; + switch (params.category) { + case '20616': + tid = 'gwxx'; + break; + case '20617': + tid = 'djgz'; + break; + case '20622': + tid = 'rsgz'; + break; + case 'xsgz': + tid = 'xsgz'; + break; + case '20618': + tid = 'kysys'; + break; + case '20619': + tid = 'bksjw'; + break; + case '20620': + tid = 'yjsjw'; + break; + default: + return false; + } + return `/scut/smae/${tid}`; + }, + }, { title: '研究生院通知公告', docs: 'https://docs.rsshub.app/routes/university#hua-nan-li-gong-da-xue', diff --git a/lib/v2/scut/router.js b/lib/v2/scut/router.js index 6c2ecfda0..171153d5e 100644 --- a/lib/v2/scut/router.js +++ b/lib/v2/scut/router.js @@ -4,5 +4,6 @@ module.exports = (router) => { router.get('/jwc/school/:category?', require('./jwc/school')); router.get('/scet/notice', require('./scet/notice')); router.get('/seie/news_center', require('./seie/news_center')); + router.get('/smae/:category?', require('./smae/notice')); router.get('/yjs', require('./yjs')); }; diff --git a/lib/v2/scut/smae/notice.js b/lib/v2/scut/smae/notice.js new file mode 100644 index 000000000..4a1535180 --- /dev/null +++ b/lib/v2/scut/smae/notice.js @@ -0,0 +1,54 @@ +// 导入必要的模组 +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const categoryMap = { + gwxx: { title: '公务信息', tag: '20616' }, + djgz: { title: '党建工作', tag: '20617' }, + rsgz: { title: '人事工作', tag: '20622' }, + xsgz: { title: '学生工作', tag: 'xsgz' }, + kysys: { title: '科研实验室', tag: '20618' }, + bksjw: { title: '本科生教务', tag: '20619' }, + yjsjw: { title: '研究生教务', tag: '20620' }, +}; + +module.exports = async (ctx) => { + const baseUrl = 'http://www2.scut.edu.cn'; + + const categoryName = ctx.params.category || 'yjsjw'; + const categoryMeta = categoryMap[categoryName]; + const url = `${baseUrl}/smae/${categoryMeta.tag}/list.htm`; + + const { data: response } = await got(url); + const $ = cheerio.load(response); + const list = $('#wp_news_w6 ul li.news') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('a'); + const pubDate = item.find('span.news_meta'); + return { + title: a.attr('title'), + link: `${baseUrl}${a.attr('href')}`, + pubDate: parseDate(pubDate.text()), + }; + }); + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: response } = await got(item.link); + const $ = cheerio.load(response); + + item.description = $('div.wp_articlecontent').html(); + + return item; + }) + ) + ); + ctx.state.data = { + title: `华南理工大学机械与汽车工程学院 - ${categoryMeta.title}`, + link: url, + item: items, + }; +}; diff --git a/website/docs/routes/university.md b/website/docs/routes/university.md index c4341e270..bebec186e 100644 --- a/website/docs/routes/university.md +++ b/website/docs/routes/university.md @@ -1813,6 +1813,16 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS ::: +### 机械与汽车工程学院 - 通知公告 {#hua-nan-li-gong-da-xue-ji-xie-yu-qi-che-gong-cheng-xue-yuan-tong-zhi-gong-gao} + + + +| 公务信息 | 党建工作 | 人事工作 | 学生工作 | 科研实验室 | 本科生教务 | 研究生教务 | +| ------- | ------- | -------- | ------- | --------- | --------- | --------- | +| gwxx | djgz | rsgz | xsgz | kysys | bksjw | yjsjw | + + + ## 华南农业大学 {#hua-nan-nong-ye-da-xue} ### 华农研讯 {#hua-nan-nong-ye-da-xue-hua-nong-yan-xun}