From 42ac513d99ff8f4fc5997b2c8d50df9e27a95072 Mon Sep 17 00:00:00 2001 From: Fatpandac <1779196284@qq.com> Date: Sun, 23 Jan 2022 03:19:03 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E4=B8=AD=E5=9B=BD=E7=A7=91=E5=AD=A6?= =?UTF-8?q?=E9=99=A2=E5=A4=A7=E5=AD=A6=20(#8733)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tony --- docs/university.md | 12 ++++++++ lib/v2/ucas/index.js | 59 +++++++++++++++++++++++++++++++++++++++ lib/v2/ucas/maintainer.js | 3 ++ lib/v2/ucas/rader.js | 47 +++++++++++++++++++++++++++++++ lib/v2/ucas/router.js | 3 ++ 5 files changed, 124 insertions(+) create mode 100644 lib/v2/ucas/index.js create mode 100644 lib/v2/ucas/maintainer.js create mode 100644 lib/v2/ucas/rader.js create mode 100644 lib/v2/ucas/router.js diff --git a/docs/university.md b/docs/university.md index bdab0b89e..9b7ddcd97 100644 --- a/docs/university.md +++ b/docs/university.md @@ -2641,6 +2641,18 @@ type 列表: +## 中国科学院大学 + +### 招聘信息 + + + +| 招聘类型 | 博士后 | 课题项目聘用 | 管理支撑人才 | 教学科研人才 | +| :------: | :----: | :----------: | :----------: | :----------: | +| 参数 | bsh | ktxmpy | glzcrc | jxkyrc | + + + ## 中国农业大学 ### 中国农业大学研招网通知公告 diff --git a/lib/v2/ucas/index.js b/lib/v2/ucas/index.js new file mode 100644 index 000000000..eb23b16c4 --- /dev/null +++ b/lib/v2/ucas/index.js @@ -0,0 +1,59 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const rootUrl = 'https://zhaopin.ucas.ac.cn'; + +const idMap = { + jxkyrc: 3, + glzcrc: 4, + ktxmpy: 5, + bsh: 6, +}; + +const titleMap = { + jxkyrc: '教学科研人才', + glzcrc: '管理支撑人才', + ktxmpy: '课题项目聘用', + bsh: '博士后', +}; + +module.exports = async (ctx) => { + const type = ctx.params.type ?? 'bsh'; + const url = `${rootUrl}/gjob/login.do?method=contentList&t=zhaopin&c=${idMap[type]}`; + const response = await got.get(url); + + const $ = cheerio.load(response.data); + const list = $('#col1_content > div.list > ul > li').get(); + + const items = await Promise.all( + list.map(async (item) => { + const title = $(item).find('a').attr('title'); + const link = rootUrl + $(item).find('a').attr('href'); + const pubDate = parseDate($(item).find('span').text()); + + const desc = await ctx.cache.tryGet(link, async () => { + const response = await got.get(link); + const pageContent = cheerio.load(response.data); + + const descDeadline = pageContent('#col1_content > div.content_head > div.top').html(); + const descContent = pageContent('#col1_content > div.entry').html(); + const desc = descDeadline + descContent; + return desc; + }); + + return { + title, + link, + pubDate, + description: desc, + }; + }) + ); + + ctx.state.data = { + title: `中国科学院大学招聘 - ${titleMap[type]}`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/ucas/maintainer.js b/lib/v2/ucas/maintainer.js new file mode 100644 index 000000000..17f4089ce --- /dev/null +++ b/lib/v2/ucas/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/job/:type?': ['Fatpandac'], +}; diff --git a/lib/v2/ucas/rader.js b/lib/v2/ucas/rader.js new file mode 100644 index 000000000..59b313dd9 --- /dev/null +++ b/lib/v2/ucas/rader.js @@ -0,0 +1,47 @@ +module.exports = { + 'ucas.ac.cn': { + _name: '中国科学院大学招聘', + zhaopin: [ + { + title: '招聘信息-博士后', + docs: 'https://docs.rsshub.app/university.html#zhong-guo-ke-xue-yuan-da-xue-zhao-pin-xin-xi', + source: '/*', + target: (params, url) => { + if (new URL(url).searchParams.get('c') === '6') { + return '/ucas/job/bsh'; + } + }, + }, + { + title: '招聘信息-课题项目聘用', + docs: 'https://docs.rsshub.app/university.html#zhong-guo-ke-xue-yuan-da-xue-zhao-pin-xin-xi', + source: '/*', + target: (params, url) => { + if (new URL(url).searchParams.get('c') === '5') { + return '/ucas/job/ktxmpy'; + } + }, + }, + { + title: '招聘信息-管理支撑人才', + docs: 'https://docs.rsshub.app/university.html#zhong-guo-ke-xue-yuan-da-xue-zhao-pin-xin-xi', + source: '/*', + target: (params, url) => { + if (new URL(url).searchParams.get('c') === '4') { + return '/ucas/job/glzcrc'; + } + }, + }, + { + title: '招聘信息-科学科研人才', + docs: 'https://docs.rsshub.app/university.html#zhong-guo-ke-xue-yuan-da-xue-zhao-pin-xin-xi', + source: '/*', + target: (params, url) => { + if (new URL(url).searchParams.get('c') === '3') { + return '/ucas/job/jxkyrc'; + } + }, + }, + ], + }, +}; diff --git a/lib/v2/ucas/router.js b/lib/v2/ucas/router.js new file mode 100644 index 000000000..cde55f593 --- /dev/null +++ b/lib/v2/ucas/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/job/:type?', require('./index')); +};