feat(route): add 中南大学计算机学院通知 (#9631)
* feat(route): add 中南大学计算机学院通知 * fix: use nullish coalescing
This commit is contained in:
@@ -3138,6 +3138,16 @@ type 列表:
|
||||
|
||||
</Route>
|
||||
|
||||
### 计算机学院
|
||||
|
||||
<Route author="j1g5awi" example="/csu/cse" path="/csu/cse/:type?" :paramsDesc="['类型']">
|
||||
|
||||
| 类型 | 学院新闻 | 通知公告 | 学术信息 | 学工动态 | 科研动态 |
|
||||
| -- | ---- | ---- | ---- | ---- | ---- |
|
||||
| 参数 | xyxw | tzgg | xsxx | xgdt | kydt |
|
||||
|
||||
</Route>
|
||||
|
||||
## 中山大学
|
||||
|
||||
### 数据科学与计算机学院动态
|
||||
|
||||
@@ -711,9 +711,6 @@ router.get('/hust/aia/notice/:type?', lazyloadRouteHandler('./routes/universitie
|
||||
// 井冈山大学
|
||||
router.get('/jgsu/jwc', lazyloadRouteHandler('./routes/universities/jgsu/jwc'));
|
||||
|
||||
// 中南大学
|
||||
router.get('/csu/job/:type?', lazyloadRouteHandler('./routes/universities/csu/job'));
|
||||
|
||||
// 山东大学 migrated to v2
|
||||
// router.get('/sdu/sc/:type?', lazyloadRouteHandler('./routes/universities/sdu/sc'));
|
||||
// router.get('/sdu/cs/:type?', lazyloadRouteHandler('./routes/universities/sdu/cs'));
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const fetch = require('./fetch_article');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://cse.csu.edu.cn/index/';
|
||||
const type = ctx.params.type ?? 'tzgg';
|
||||
const link = url + type + '.htm';
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.download li').get();
|
||||
const out = await Promise.all(
|
||||
list.map((item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const address = new URL($('a').attr('href'), url);
|
||||
const title = $('a').text();
|
||||
const pubDate = $('span').text();
|
||||
return ctx.cache.tryGet(address, async () => {
|
||||
const single = await fetch(address);
|
||||
single.title = title;
|
||||
single.pubDate = parseDate(pubDate, 'YYYY/MM/DD');
|
||||
return single;
|
||||
});
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async function fetch(address) {
|
||||
const res = await got(address);
|
||||
const $ = cheerio.load(res.data);
|
||||
return {
|
||||
description: $('[name="_newscontent_fromname"]').html(),
|
||||
link: address,
|
||||
guid: address,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/cse/:type?': ['j1g5awi'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'csu.edu.cn': {
|
||||
_name: '中南大学',
|
||||
cse: [
|
||||
{
|
||||
title: '计算机学院',
|
||||
docs: 'https://docs.rsshub.app/university.html#zhong-nan-da-xue',
|
||||
source: ['/index/:type'],
|
||||
target: (params) => `/csu/cse/${params.type.substring(0, 4)}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/cse/:type?', require('./cse'));
|
||||
router.get('/job/:type?', require('./job'));
|
||||
};
|
||||
Reference in New Issue
Block a user