mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 10:15:23 +08:00
feat(route): add 厦门大学航院 (#8137)
* feat(route): add 厦门大学航院 * Simplify the code * Fix the problem of tryGet
This commit is contained in:
@@ -653,6 +653,19 @@ xskb1 对应 <http://www.auto.uestc.edu.cn/index/xskb1.htm>
|
|||||||
| -------- | -------- |
|
| -------- | -------- |
|
||||||
| jxtz | zjjz |
|
| jxtz | zjjz |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 厦门大学
|
||||||
|
|
||||||
|
## 航空航天学院
|
||||||
|
<Route author="jch12138" example="/xmu/aero/yjsjw" path="/xmu/aero/:type" :paramsDesc="['分类见下表']"/>
|
||||||
|
|
||||||
|
| 通知公告 | 本科生教务 | 研究生教务 |
|
||||||
|
| :--------: | :--------: | :--------: |
|
||||||
|
| tzgg | bksjw | yjsjw|
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
|
||||||
## 复旦大学继续教育学院
|
## 复旦大学继续教育学院
|
||||||
|
|
||||||
### 成人夜大通知公告
|
### 成人夜大通知公告
|
||||||
|
|||||||
@@ -945,6 +945,9 @@ router.get('/lyu/news/:type', lazyloadRouteHandler('./routes/universities/lyu/ne
|
|||||||
// 福州大学
|
// 福州大学
|
||||||
router.get('/fzu/:type', lazyloadRouteHandler('./routes/universities/fzu/news'));
|
router.get('/fzu/:type', lazyloadRouteHandler('./routes/universities/fzu/news'));
|
||||||
|
|
||||||
|
// 厦门大学
|
||||||
|
router.get('/xmu/aero/:type', lazyloadRouteHandler('./routes/universities/xmu/aero'));
|
||||||
|
|
||||||
// ifanr
|
// ifanr
|
||||||
router.get('/ifanr/:channel?', lazyloadRouteHandler('./routes/ifanr/index'));
|
router.get('/ifanr/:channel?', lazyloadRouteHandler('./routes/ifanr/index'));
|
||||||
|
|
||||||
|
|||||||
63
lib/routes/universities/xmu/aero.js
Normal file
63
lib/routes/universities/xmu/aero.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
const host = 'https://aerospace.xmu.edu.cn';
|
||||||
|
|
||||||
|
const urlMap = {
|
||||||
|
tzgg: '/xydt/tzgg.htm',
|
||||||
|
bksjw: '/jwxx/bksjw.htm',
|
||||||
|
yjsjw: '/jwxx/yjsjw.htm'
|
||||||
|
};
|
||||||
|
|
||||||
|
const titleMap = {
|
||||||
|
tzgg: '通知公告',
|
||||||
|
bksjw: '本科生教务',
|
||||||
|
yjsjw: '研究生教务'
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const type = ctx.params.type || '';
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: host + urlMap[type],
|
||||||
|
});
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
const $ = cheerio.load(data, { decodeEntities: false });
|
||||||
|
|
||||||
|
const list = $('body > div.centers > div.other_right > ul > li')
|
||||||
|
.map((index, item) => {
|
||||||
|
item = $(item);
|
||||||
|
const $a = item.find('a');
|
||||||
|
return {
|
||||||
|
title: $a.attr('title'),
|
||||||
|
link: host + $a.attr('href').slice(2,)
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const result = await Promise.all(
|
||||||
|
list.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailResponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: item.link,
|
||||||
|
});
|
||||||
|
const content = cheerio.load(detailResponse.data, { decodeEntities: false });
|
||||||
|
|
||||||
|
item.description = content('#vsb_content > div').html();
|
||||||
|
|
||||||
|
const date = content('body > div.centers > div.other_right > form > div > div.news-info.clearfix > span:nth-child(2)').text();
|
||||||
|
item.pubDate = parseDate(date, '发布时间:YYYY年MM月DD日');
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
ctx.state.data = {
|
||||||
|
title: titleMap[type],
|
||||||
|
link: host,
|
||||||
|
item: result,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user