diff --git a/docs/university.md b/docs/university.md index cbb03e4aa..a937d0f7f 100644 --- a/docs/university.md +++ b/docs/university.md @@ -283,6 +283,10 @@ pageClass: routes ::: +### 人才招聘 + + + ## 常州大学 ### 教务处 diff --git a/lib/v2/bupt/maintainer.js b/lib/v2/bupt/maintainer.js new file mode 100644 index 000000000..1a48219f7 --- /dev/null +++ b/lib/v2/bupt/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/rczp': ['nczitzk'], +}; diff --git a/lib/v2/bupt/radar.js b/lib/v2/bupt/radar.js new file mode 100644 index 000000000..0a9c2df63 --- /dev/null +++ b/lib/v2/bupt/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'bupt.edu.cn': { + _name: '北京邮电大学', + '.': [ + { + title: '人才招聘', + docs: 'https://docs.rsshub.app/university.html#bei-jing-you-dian-da-xue-ren-cai-zhao-pin', + source: ['/'], + target: '/bupt/rczp', + }, + ], + }, +}; diff --git a/lib/v2/bupt/rczp.js b/lib/v2/bupt/rczp.js new file mode 100644 index 000000000..017115538 --- /dev/null +++ b/lib/v2/bupt/rczp.js @@ -0,0 +1,51 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.bupt.edu.cn'; + const currentUrl = `${rootUrl}/rczp.htm`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.date-block') + .map((_, item) => { + item = $(item); + + return { + title: item.next().text(), + link: `${rootUrl}/${item.next().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('.v_news_content').html(); + item.pubDate = timezone(parseDate(content('.info span').first().text().replace('发布时间 : ', '')), +8); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/bupt/router.js b/lib/v2/bupt/router.js new file mode 100644 index 000000000..44d728461 --- /dev/null +++ b/lib/v2/bupt/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/rczp', require('./rczp')); +};