diff --git a/assets/radar-rules.js b/assets/radar-rules.js index f2df5a38bc..85f48a8b11 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -1357,4 +1357,52 @@ }, ], }, + 'hrbeu.edu.cn': { + _name: '哈尔滨工程大学', + yjsy: [ + { + title: '研究生院 - 通知公告', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/yjsy/announcement', + }, + { + title: '研究生院 - 新闻动态', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/yjsy/news', + }, + ], + uae: [ + { + title: '水声学院 - 新闻动态', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/shuisheng/xwdt', + }, + { + title: '研究生院 - 通知公告', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/shuisheng/tzgg', + }, + ], + }, + 'gongxue.cn': { + _name: '工学网', + '.': [ + { + title: '要闻', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/gongxue/yw', + }, + { + title: '时讯', + docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', + source: '/*', + target: '/heu/gongxue/sx', + }, + ], + }, }); diff --git a/docs/university.md b/docs/university.md index 8841cde893..1143e67a34 100644 --- a/docs/university.md +++ b/docs/university.md @@ -387,7 +387,7 @@ category 列表: ### 研究生院 - + | 通知公告 | 新闻动态 | | ------------ | -------- | @@ -397,7 +397,7 @@ category 列表: ### 工学网 - + | 要闻 | 时讯 | | ---- | ---- | @@ -405,6 +405,16 @@ category 列表: +### 水声工程学院通知 + + + +| 新闻动态 | 通知公告 | +| -------- | -------- | +| xwdt | tzgg | + + + ## 哈尔滨工业大学 ### 哈尔滨工业大学教务处通知公告 diff --git a/lib/router.js b/lib/router.js index 76dde1b081..7532d00af9 100644 --- a/lib/router.js +++ b/lib/router.js @@ -623,6 +623,7 @@ router.get('/nchu/jwc/:type?', require('./routes/universities/nchu/jwc')); router.get('/heu/ugs/news/:author?/:category?', require('./routes/universities/heu/ugs/news')); router.get('/heu/yjsy/:type?', require('./routes/universities/heu/yjsy')); router.get('/heu/gongxue/:type?', require('./routes/universities/heu/gongxue')); +router.get('/heu/shuisheng/:type?', require('./routes/universities/heu/shuisheng')); // 重庆大学 router.get('/cqu/jwc/announcement', require('./routes/universities/cqu/jwc/announcement')); diff --git a/lib/routes/universities/heu/gongxue.js b/lib/routes/universities/heu/gongxue.js index 14d90bcbe3..0f77a0c0f8 100644 --- a/lib/routes/universities/heu/gongxue.js +++ b/lib/routes/universities/heu/gongxue.js @@ -47,6 +47,7 @@ module.exports = async (ctx) => { const out = await Promise.all( urlList.map(async (itemUrl, index) => { + const itemYear = itemUrl.substring(6, 10); itemUrl = url.resolve(baseUrl, itemUrl); if (itemUrl.indexOf('.html') !== -1) { const cache = await ctx.cache.get(itemUrl); @@ -64,7 +65,7 @@ module.exports = async (ctx) => { title: titleList[index], link: itemUrl, description: $('.wenzhangzhengwen').html(), - pubDate: '2020-' + dateList[index], + pubDate: itemYear + '-' + dateList[index], }; ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); diff --git a/lib/routes/universities/heu/shuisheng.js b/lib/routes/universities/heu/shuisheng.js new file mode 100644 index 0000000000..62e69f6943 --- /dev/null +++ b/lib/routes/universities/heu/shuisheng.js @@ -0,0 +1,84 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const url = require('url'); + +const baseUrl = 'http://uae.hrbeu.edu.cn'; + +const typeMap = { + xwdt: { + name: '新闻动态', + url: '/3751/list.htm', + }, + tzgg: { + name: '通知公告', + url: '/3752/list.htm', + }, +}; + +module.exports = async (ctx) => { + const type = ctx.params.type || 'tzgg'; + const link = baseUrl + typeMap[type].url; + const response = await got({ + method: 'get', + url: link, + headers: { + Referer: baseUrl, + }, + }); + const $ = cheerio.load(response.data); + + const urlList = $('.column-news-item') + .slice(0, 10) + .map((i, e) => $(e).attr('href')) + .get(); + + const titleList = $('.column-news-item') + .slice(0, 10) + .map((i, e) => $('.column-news-title', e).text()) + .get(); + + const dateList = $('.column-news-item') + .slice(0, 10) + .map((i, e) => $('.column-news-date', e).text()) + .get(); + + const out = await Promise.all( + urlList.map(async (itemUrl, index) => { + itemUrl = url.resolve(baseUrl, itemUrl); + if (itemUrl.indexOf('.htm') !== -1) { + const cache = await ctx.cache.get(itemUrl); + if (cache) { + return Promise.resolve(JSON.parse(cache)); + } + const response = await got.get(itemUrl); + const $ = cheerio.load(response.data); + const single = { + title: titleList[index], + link: itemUrl, + description: $('.wp_articlecontent') + .html() + .replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`) + .replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`) + .trim(), + pubDate: dateList[index], + }; + ctx.cache.set(itemUrl, JSON.stringify(single)); + return Promise.resolve(single); + } else { + const single = { + title: titleList[index], + link: itemUrl, + description: '此链接为文件,请点击下载', + pubDate: dateList[index], + }; + return Promise.resolve(single); + } + }) + ); + + ctx.state.data = { + title: '水声工程学院-' + typeMap[type].name, + link: link, + item: out, + }; +};