feat:add uestc cqe (#5750)

This commit is contained in:
truobel
2020-10-02 23:45:56 +01:00
committed by GitHub
parent c2fd937417
commit 59bc015863
3 changed files with 51 additions and 0 deletions
+10
View File
@@ -372,6 +372,16 @@ xskb1 对应 <http://www.auto.uestc.edu.cn/index/xskb1.htm>
</Route>
### 文化素质教育中心
<Route author="truobel" example="/uestc/cqe/hdyg" path="/uestc/cqe/:type?" :paramsDesc="['默认为 `hdyg`']">
| 活动预告 | 通知 | 课程通知 | 立人班选拔 |
| -------- | ---- | -------- | ---------- |
| hdyg | tz | kctz | lrxb |
</Route>
## 东北大学
### 东北大学新闻网
+1
View File
@@ -739,6 +739,7 @@ router.get('/uestc/jwc/:type?', require('./routes/universities/uestc/jwc'));
router.get('/uestc/news/:type?', require('./routes/universities/uestc/news'));
router.get('/uestc/auto/:type?', require('./routes/universities/uestc/auto'));
router.get('/uestc/cs/:type?', require('./routes/universities/uestc/cs'));
router.get('/uestc/cqe/:type?', require('./routes/universities/uestc/cqe'));
// 云南大学
router.get('/ynu/grs/zytz', require('./routes/universities/ynu/grs/zytz'));
+40
View File
@@ -0,0 +1,40 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const rootlink = 'http://cqe.uestc.edu.cn/';
const mapUrl = {
hdyg: 'xwgg/hdyg.htm',
tz: 'xwgg/tzgg.htm',
kctz: 'kcjs/tzgg.htm',
lrxb: 'ldljy/tzgg.htm',
};
const mapTitle = {
hdyg: '成电文化素质教育中心-活动预告',
tz: '成电文化素质教育中心-通知',
kctz: '成电文化素质教育中心-课程通知',
lrxb: '立人班选拔',
};
module.exports = async (ctx) => {
const type = ctx.params.type || 'hdyg';
const response = await got({
method: 'get',
url: rootlink + mapUrl[type],
});
const data = response.data;
const $ = cheerio.load(data);
ctx.state.data = {
title: mapTitle[type],
link: rootlink + mapUrl[type],
item: $('div.Newslist>ul>li')
.map((_, item) => ({
title: $(item).find('a').attr('title'),
link: $(item).find('a').attr('href').replace('..', rootlink),
pubDate: $(item).find('span').text().substr(1, 10),
}))
.get(),
};
};