feat(route): 华南理工大学 - 机械与汽车工程学院 (#13310)
* add route of SCUT SMAE * resolve 'Route' in md
This commit is contained in:
parent
0d0f482ba7
commit
5d5f63dcec
|
|
@ -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'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -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}
|
||||
|
||||
<Route author="Ermaotie" example="/scut/smae/yjsjw" path="/scut/smae/:category?" radar="1" paramsDesc={['通知分类,默认为 `yjsjw`']}>
|
||||
|
||||
| 公务信息 | 党建工作 | 人事工作 | 学生工作 | 科研实验室 | 本科生教务 | 研究生教务 |
|
||||
| ------- | ------- | -------- | ------- | --------- | --------- | --------- |
|
||||
| gwxx | djgz | rsgz | xsgz | kysys | bksjw | yjsjw |
|
||||
|
||||
</Route>
|
||||
|
||||
## 华南农业大学 {#hua-nan-nong-ye-da-xue}
|
||||
|
||||
### 华农研讯 {#hua-nan-nong-ye-da-xue-hua-nong-yan-xun}
|
||||
|
|
|
|||
Loading…
Reference in New Issue