diff --git a/lib/v2/hrbeu/radar.js b/lib/v2/hrbeu/radar.js index 8f2694088..f9a636d8c 100644 --- a/lib/v2/hrbeu/radar.js +++ b/lib/v2/hrbeu/radar.js @@ -63,10 +63,10 @@ module.exports = { ], uae: [ { - title: '水声学院', + title: '水声工程学院', docs: 'https://docs.rsshub.app/routes/university#ha-er-bin-gong-cheng-da-xue', - source: '/:id/list.htm', - target: '/hrbeu/uae/list/:id', + source: '/:id.htm', + target: '/hrbeu/uae/:id', }, ], ugs: [ diff --git a/lib/v2/hrbeu/router.js b/lib/v2/hrbeu/router.js index e9e4dd4b4..dd5f2a773 100644 --- a/lib/v2/hrbeu/router.js +++ b/lib/v2/hrbeu/router.js @@ -4,7 +4,7 @@ module.exports = function (router) { router.get('/job/list/:id', require('./job/list')); router.get('/gx/card/:column/:id?', require('./gx/card')); router.get('/gx/list/:column/:id?', require('./gx/list')); - router.get('/uae/list/:id', require('./uae/list')); + router.get('/uae/:id', require('./uae/news')); router.get('/ugs/news/:author?/:category?', require('./ugs/news')); router.get('/yjsy/list/:id', require('./yjsy/list')); }; diff --git a/lib/v2/hrbeu/uae/list.js b/lib/v2/hrbeu/uae/list.js deleted file mode 100644 index aedf60d14..000000000 --- a/lib/v2/hrbeu/uae/list.js +++ /dev/null @@ -1,57 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const { parseDate } = require('@/utils/parse-date'); -const { finishArticleItem } = require('@/utils/wechat-mp'); -const rootUrl = 'http://uae.hrbeu.edu.cn'; - -module.exports = async (ctx) => { - const id = ctx.params.id; - - const response = await got(`${rootUrl}/${id}/list.htm`, { - headers: { - Referer: rootUrl, - }, - }); - - const $ = cheerio.load(response.data); - - const bigTitle = $('h2.column-title').text(); - - const list = $('a.column-news-item') - .map((_, item) => { - let link = $(item).attr('href'); - if (link.includes('page.htm')) { - link = `${rootUrl}${link}`; - } - return { - title: $(item).find('span.column-news-title').text(), - pubDate: parseDate($(item).find('span.column-news-date').text()), - link, - }; - }) - .get(); - - const items = await Promise.all( - list.map((item) => - ctx.cache.tryGet(item.link, async () => { - if (item.link.includes('page.htm')) { - const detailResponse = await got(item.link); - const content = cheerio.load(detailResponse.data); - item.description = content('div.wp_articlecontent').html(); - item.title = content('h1.arti-title').text(); - } else if (new URL(item.link).hostname === 'mp.weixin.qq.com') { - await finishArticleItem(ctx, item); - } else { - item.description = '本文需跳转,请点击标题后阅读'; - } - return item; - }) - ) - ); - - ctx.state.data = { - title: '水声学院-' + bigTitle, - link: `${rootUrl}/${id}/list.htm`, - item: items, - }; -}; diff --git a/lib/v2/hrbeu/uae/news.js b/lib/v2/hrbeu/uae/news.js new file mode 100644 index 000000000..8d5c9d82b --- /dev/null +++ b/lib/v2/hrbeu/uae/news.js @@ -0,0 +1,66 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const { finishArticleItem } = require('@/utils/wechat-mp'); + +module.exports = async (ctx) => { + const id = ctx.params.id.replace(/-/g, '/'); + const host = 'http://uae.hrbeu.edu.cn'; + const url = `${host}/${id}.htm`; + + const response = await got(url, { + headers: { + Referer: host, + }, + }); + + const $ = cheerio.load(response.data); + const title = $('h2').text(); + const items = $('li.wow.fadeInUp') + .map((_, item) => { + const title = $(item).find('a').attr('title'); + let link = $(item).find('a').attr('href'); + if (!link.startsWith('http')) { + link = `${host}/${link}`; + } + const pubDate = parseDate( + $(item) + .find('div.date') + .text() + .replace(/(.*)\/(.*)/g, '$2-$1') + ); + return { + title, + pubDate, + link, + }; + }) + .get(); + + const item = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + if (new URL(item.link).hostname === 'uae.hrbeu.edu.cn') { + const resp = await got(item.link); + const $1 = cheerio.load(resp.data); + item.description = $1('div.art-body').html(); + } else if (new URL(item.link).hostname === 'news.hrbeu.edu.cn') { + const resp = await got(item.link); + const $1 = cheerio.load(resp.data); + item.description = $1('div#print').html(); + } else if (new URL(item.link).hostname === 'mp.weixin.qq.com') { + await finishArticleItem(ctx, item); + } else { + item.description = '本文需跳转,请点击标题后阅读'; + } + return item; + }) + ) + ); + + ctx.state.data = { + title: `水声工程学院 - ${title}`, + link: url, + item, + }; +}; diff --git a/website/docs/routes/university.md b/website/docs/routes/university.md index bfaddcec6..29994e9b7 100644 --- a/website/docs/routes/university.md +++ b/website/docs/routes/university.md @@ -1473,11 +1473,11 @@ category 列表: ### 水声工程学院 {#ha-er-bin-gong-cheng-da-xue-shui-sheng-gong-cheng-xue-yuan} - + -| 新闻动态 | 通知公告 | 其他 | -| :------: | :------: | :--: | -| 3751 | 3752 | ... | +| 新闻动态 | 通知公告 | 科学研究/科研动态 | +| :------: | :------: | :------------: | +| xwdt | tzgg | kxyj-kydt |