diff --git a/docs/university.md b/docs/university.md index 15fd874904..17154c7418 100644 --- a/docs/university.md +++ b/docs/university.md @@ -653,6 +653,19 @@ xskb1 对应 | -------- | -------- | | jxtz | zjjz | + + +## 厦门大学 + +## 航空航天学院 + + +| 通知公告 | 本科生教务 | 研究生教务 | +| :--------: | :--------: | :--------: | +| tzgg | bksjw | yjsjw| + + + ## 复旦大学继续教育学院 ### 成人夜大通知公告 diff --git a/lib/router.js b/lib/router.js index a87a5989eb..17662a7885 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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('/xmu/aero/:type', lazyloadRouteHandler('./routes/universities/xmu/aero')); + // ifanr router.get('/ifanr/:channel?', lazyloadRouteHandler('./routes/ifanr/index')); diff --git a/lib/routes/universities/xmu/aero.js b/lib/routes/universities/xmu/aero.js new file mode 100644 index 0000000000..d9eb2b87be --- /dev/null +++ b/lib/routes/universities/xmu/aero.js @@ -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, + }; +};