From c302a5853ed2bf87aea5325fa0d57b86bd6cb787 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Sat, 27 Nov 2021 16:33:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E5=AF=B9=E5=A4=96?= =?UTF-8?q?=E7=BB=8F=E6=B5=8E=E8=B4=B8=E6=98=93=E5=A4=A7=E5=AD=A6=E4=BA=BA?= =?UTF-8?q?=E5=8A=9B=E8=B5=84=E6=BA=90=E5=A4=84=20(#8372)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/university.md | 16 ++++++++++++ lib/v2/uibe/hr.js | 54 +++++++++++++++++++++++++++++++++++++++ lib/v2/uibe/maintainer.js | 3 +++ lib/v2/uibe/radar.js | 13 ++++++++++ lib/v2/uibe/router.js | 3 +++ 5 files changed, 89 insertions(+) create mode 100644 lib/v2/uibe/hr.js create mode 100644 lib/v2/uibe/maintainer.js create mode 100644 lib/v2/uibe/radar.js create mode 100644 lib/v2/uibe/router.js diff --git a/docs/university.md b/docs/university.md index d998dde8a5..a247f9fdcf 100644 --- a/docs/university.md +++ b/docs/university.md @@ -655,6 +655,22 @@ xskb1 对应 +## 对外经济贸易大学 + +### 人力资源处 + + + +::: tip 提示 + +如 [通知公告](http://hr.uibe.edu.cn/tzgg) 的 URL 为 ,其路由为 [`/uibe/hr/tzgg`](https://rsshub.app/uibe/hr/tzgg) + +如 [教师招聘](http://hr.uibe.edu.cn/jszp) 中的 [招聘信息](http://hr.uibe.edu.cn/jszp/zpxx) 的 URL 为 ,其路由为 [`/uibe/hr/jszp/zpxx`](https://rsshub.app/uibe/jszp/zpxx) + +::: + + + ## 福州大学 ### 教务处通知 diff --git a/lib/v2/uibe/hr.js b/lib/v2/uibe/hr.js new file mode 100644 index 0000000000..b1cac947b3 --- /dev/null +++ b/lib/v2/uibe/hr.js @@ -0,0 +1,54 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const category = ctx.params.category ?? 'tzgg'; + const type = ctx.params.type ?? ''; + + const rootUrl = 'http://hr.uibe.edu.cn'; + const currentUrl = `${rootUrl}/${category}${type ? `/${type}` : ''}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.lawul, .longul') + .find('li a') + .map((_, item) => { + item = $(item); + + return { + title: item.find('p').text(), + link: `${currentUrl}/${item.attr('href')}`, + }; + }) + .get(); + + const items = 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); + + item.description = content('.gp-article').html(); + item.pubDate = parseDate(content('#shareTitle').next().text().replace('时间:', '')); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${$('.picTit').text()} - 对外经济贸易大学人力资源处`, + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/uibe/maintainer.js b/lib/v2/uibe/maintainer.js new file mode 100644 index 0000000000..135055adbf --- /dev/null +++ b/lib/v2/uibe/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/hr/:category?/:type?': ['nczitzk'], +}; diff --git a/lib/v2/uibe/radar.js b/lib/v2/uibe/radar.js new file mode 100644 index 0000000000..ee456b2b97 --- /dev/null +++ b/lib/v2/uibe/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'uibe.edu.cn': { + _name: '对外经济贸易大学', + hr: [ + { + title: '人力资源处', + docs: 'https://docs.rsshub.app/university.html#dui-wai-jing-ji-mao-yi-da-xue-ren-li-zi-yuan-chu', + source: ['/:category/:type', '/:category', '/'], + target: '/uibe/hr/:category?/:type?', + }, + ], + }, +}; diff --git a/lib/v2/uibe/router.js b/lib/v2/uibe/router.js new file mode 100644 index 0000000000..14a927a6b4 --- /dev/null +++ b/lib/v2/uibe/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/hr/:category?/:type?', require('./hr')); +};