diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 29bed7cfc3..de11a8ee8f 100755 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -1410,30 +1410,27 @@ title: '水声学院 - 新闻动态', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', - target: '/heu/shuisheng/xwdt', + target: '/heu/uae/xwdt', }, { title: '研究生院 - 通知公告', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', - target: '/heu/shuisheng/tzgg', + target: '/heu/uae/tzgg', }, ], - }, - 'gongxue.cn': { - _name: '工学网', - '.': [ + news: [ { - title: '要闻', + title: '工学新闻 - 要闻', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', - target: '/heu/gongxue/yw', + target: '/heu/news/yw', }, { - title: '时讯', + title: '工学新闻 - 时讯', docs: 'https://docs.rsshub.app/university.html#ha-er-bin-gong-cheng-da-xue', source: '/*', - target: '/heu/gongxue/sx', + target: '/heu/news/sx', }, ], }, diff --git a/docs/university.md b/docs/university.md index 7a7a09424e..99467e37bf 100644 --- a/docs/university.md +++ b/docs/university.md @@ -425,7 +425,7 @@ category 列表: ### 研究生院 - + | 通知公告 | 新闻动态 | 国家公派项目 | 国际合作与交流项目 | | ------------ | -------- | ------------ | ------------------ | @@ -435,7 +435,7 @@ category 列表: ### 就业服务平台 - + | 通知公告 | | -------- | @@ -443,9 +443,9 @@ category 列表: -### 工学网 +### 工学新闻 - + | 要闻 | 时讯 | | ---- | ---- | @@ -455,7 +455,7 @@ category 列表: ### 水声工程学院通知 - + | 新闻动态 | 通知公告 | | -------- | -------- | diff --git a/lib/router.js b/lib/router.js index c7094a43c6..bd75326a2b 100755 --- a/lib/router.js +++ b/lib/router.js @@ -640,8 +640,10 @@ 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('/heu/gongxue/:type?', require('./routes/universities/heu/news')); +router.get('/heu/news/:type?', require('./routes/universities/heu/news')); +router.get('/heu/shuisheng/:type?', require('./routes/universities/heu/uae')); +router.get('/heu/uae/:type?', require('./routes/universities/heu/uae')); router.get('/heu/job/:type?', require('./routes/universities/heu/job')); // 重庆大学 diff --git a/lib/routes/universities/heu/gongxue.js b/lib/routes/universities/heu/news.js similarity index 54% rename from lib/routes/universities/heu/gongxue.js rename to lib/routes/universities/heu/news.js index 0f77a0c0f8..d4aac3807f 100644 --- a/lib/routes/universities/heu/gongxue.js +++ b/lib/routes/universities/heu/news.js @@ -1,18 +1,17 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); const url = require('url'); -const iconv = require('iconv-lite'); -const baseUrl = 'http://gongxue.cn'; +const baseUrl = 'http://news.hrbeu.edu.cn'; const typeMap = { yw: { name: '要闻', - url: '/news/ShowClass.asp?ClassID=4383', + url: '/xw/yw.htm', }, sx: { name: '时讯', - url: '/news/ShowClass.asp?ClassID=4315', + url: '/xw/sx.htm', }, }; @@ -25,47 +24,39 @@ module.exports = async (ctx) => { headers: { Referer: baseUrl, }, - responseType: 'buffer', }); - const responseHtml = iconv.decode(response.data, 'gbk'); - const $ = cheerio.load(responseHtml); + const $ = cheerio.load(response.data); - const urlList = $('.wenzhangzhengwen tr:nth-child(-n+20)') + const urlList = $('.list-left-ul .txt-elise') .slice(0, 10) .map((i, e) => $('a', e).attr('href')) .get(); - const titleList = $('.wenzhangzhengwen tr:nth-child(-n+20)') + const titleList = $('.list-left-ul .txt-elise') .slice(0, 10) - .map((i, e) => $('a', e).text()) + .map((i, e) => $('a', e).attr('title')) .get(); - const dateList = $('.wenzhangzhengwen tr:nth-child(-n+20)') + const dateList = $('.list-left-ul .txt-elise') .slice(0, 10) - .map((i, e) => $('td[align="right"]', e).text()) + .map((i, e) => $('span', e).text()) .get(); 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) { + if (itemUrl.indexOf('.htm') !== -1) { const cache = await ctx.cache.get(itemUrl); if (cache) { return Promise.resolve(JSON.parse(cache)); } - const response = await got({ - method: 'get', - url: itemUrl, - responseType: 'buffer', - }); - const responseHtmlItem = iconv.decode(response.data, 'gbk'); - const $ = cheerio.load(responseHtmlItem); + const response = await got.get(itemUrl); + const $ = cheerio.load(response.data); const single = { title: titleList[index], link: itemUrl, - description: $('.wenzhangzhengwen').html(), - pubDate: itemYear + '-' + dateList[index], + description: $('.v_news_content').html(), + pubDate: dateList[index], }; ctx.cache.set(itemUrl, JSON.stringify(single)); return Promise.resolve(single); @@ -73,7 +64,7 @@ module.exports = async (ctx) => { const single = { title: titleList[index], link: itemUrl, - description: '此链接为文件,请点击下载', + description: '此链接为跳转,点击标题查看', pubDate: dateList[index], }; return Promise.resolve(single); @@ -82,7 +73,7 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: '工学网-' + typeMap[type].name, + title: '工学新闻-' + typeMap[type].name, link: link, item: out, }; diff --git a/lib/routes/universities/heu/shuisheng.js b/lib/routes/universities/heu/uae.js similarity index 100% rename from lib/routes/universities/heu/shuisheng.js rename to lib/routes/universities/heu/uae.js