diff --git a/docs/university.md b/docs/university.md index 3676fe8168..f9bf8e16d5 100644 --- a/docs/university.md +++ b/docs/university.md @@ -372,6 +372,16 @@ xskb1 对应 +### 文化素质教育中心 + + + +| 活动预告 | 通知 | 课程通知 | 立人班选拔 | +| -------- | ---- | -------- | ---------- | +| hdyg | tz | kctz | lrxb | + + + ## 东北大学 ### 东北大学新闻网 diff --git a/lib/router.js b/lib/router.js index 3928a15082..a636c2aed8 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/universities/uestc/cqe.js b/lib/routes/universities/uestc/cqe.js new file mode 100644 index 0000000000..04b47339f1 --- /dev/null +++ b/lib/routes/universities/uestc/cqe.js @@ -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(), + }; +};