diff --git a/docs/university.md b/docs/university.md index bd456f846..bf1dbe8d2 100644 --- a/docs/university.md +++ b/docs/university.md @@ -1170,3 +1170,16 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet ### 数据科学与计算机学院动态 + +## 武汉大学 + +### 计算机学院公告 + + + +| 公告类型 | 新闻动态 | 学术讲座 | 学院通知 | 公示公告 | +| -------- | -------- | -------- | -------- | -------- | +| 参数 | 0 | 1 | 2 | 3 | + + diff --git a/lib/router.js b/lib/router.js index 4c2dbea1b..6703b5f14 100644 --- a/lib/router.js +++ b/lib/router.js @@ -662,6 +662,9 @@ router.get('/kmust/jwc/:type?', require('./routes/universities/kmust/jwc')); router.get('/kmust/job/careers/:type?', require('./routes/universities/kmust/job/careers')); router.get('/kmust/job/jobfairs', require('./routes/universities/kmust/job/jobfairs')); +// 武汉大学 +router.get('/whu/cs/:type', require('./routes/universities/whu/cs')); + // 华中科技大学 router.get('/hust/auto/notice/:type?', require('./routes/universities/hust/aia/notice')); router.get('/hust/auto/news/', require('./routes/universities/hust/aia/news')); diff --git a/lib/routes/universities/whu/cs.js b/lib/routes/universities/whu/cs.js new file mode 100644 index 000000000..85811c210 --- /dev/null +++ b/lib/routes/universities/whu/cs.js @@ -0,0 +1,51 @@ +const got = require('@/utils/got'); +const date = require('@/utils/date'); +const cheerio = require('cheerio'); + +const baseUrl = 'http://cs.whu.edu.cn'; +const typelist = ['新闻动态', '学术讲座', '学院通知', '公示公告']; + +module.exports = async (ctx) => { + const type = parseInt(ctx.params.type); + const response = await got.get(baseUrl); + const $ = cheerio.load(response.data); + let list; + if (type === 0) { + list = $('ul.txt-list>li'); + } else if (type === 1) { + list = $('div.talks-list'); + } else if (type === 2) { + list = $('div.fl>ul.list-wrap>li'); + } else if (type === 3) { + list = $('div.fr>ul.list-wrap>li'); + } + + ctx.state.data = { + title: `${typelist[type]} - 武汉大学计算机学院`, + link: baseUrl, + description: `${typelist[type]} - 武汉大学计算机学院`, + item: + list && + list + .map((index, item) => ({ + title: $(item) + .find('a') + .attr('title'), + description: $(item) + .find('p') + .text() + .trim(), + pubDate: date( + $(item) + .find('span') + .text() + ), + link: + baseUrl + + $(item) + .find('a') + .attr('href'), + })) + .get(), + }; +};