diff --git a/docs/university.md b/docs/university.md index 6700eab450..f3f116cc3c 100644 --- a/docs/university.md +++ b/docs/university.md @@ -830,6 +830,10 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet +### 学工部通知公告 + + + ## 四川旅游学院 ### 信息与工程学院动态公告列表 diff --git a/lib/router.js b/lib/router.js index 6197f10b4e..e322c1fa93 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1180,6 +1180,7 @@ router.get('/babykingdom/:id/:order?', require('./routes/babykingdom')); // 四川大学 router.get('/scu/jwc/notice', require('./routes/universities/scu/jwc')); +router.get('/scu/xg/notice', require('./routes/universities/scu/xg')); // 浙江工商大学 router.get('/zjgsu/tzgg', require('./routes/universities/zjgsu/tzgg/scripts')); diff --git a/lib/routes/universities/scu/xg.js b/lib/routes/universities/scu/xg.js new file mode 100644 index 0000000000..b218e265fc --- /dev/null +++ b/lib/routes/universities/scu/xg.js @@ -0,0 +1,50 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +async function load_detail(list, cache) { + return await Promise.all( + list.map(async (item) => { + const notice_item = cheerio.load(item); + const url = 'http://xsc.scu.edu.cn' + notice_item('a').attr('href'); + return await cache.tryGet(url, async () => { + const detail_response = await got({ + method: 'get', + url: url, + headers: { + Referer: 'http://xsc.scu.edu.cn/WEBSITE/XG', + Host: 'xsc.scu.edu.cn', + }, + }); + const detail = cheerio.load(detail_response.data); + return { + title: notice_item('a').attr('title'), + description: detail('.news-content').html(), + link: url, + }; + }); + }) + ); +} + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'http://xsc.scu.edu.cn/WEBSITE/XG', + headers: { + Host: 'xsc.scu.edu.cn', + }, + }); + + const data = response.data; + + const $ = cheerio.load(data); + const list = $('.news-pannel.notice-news > .news-body > .news-list > ul > li').get(); + + const detail = await load_detail(list, ctx.cache); + + ctx.state.data = { + title: '四川大学学工部 - 通知公告', + link: 'http://xsc.scu.edu.cn/WEBSITE/XG', + item: detail, + }; +};