From 2d985cfa8491eb28ffe6ce0c8ed5ff908ce60196 Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Fri, 18 Oct 2019 11:48:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8D=8E=E4=B8=AD?= =?UTF-8?q?=E5=B8=88=E8=8C=83=E5=A4=A7=E5=AD=A6=E5=B0=B1=E4=B8=9A=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20(#3257)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/university.md | 12 +++++++ lib/router.js | 3 ++ lib/routes/universities/ccnu/career.js | 43 ++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 lib/routes/universities/ccnu/career.js diff --git a/docs/university.md b/docs/university.md index d800979a06..a567967a14 100644 --- a/docs/university.md +++ b/docs/university.md @@ -410,6 +410,18 @@ category 列表: +## 华中师范大学 + +### 就业信息 + + + +| 校内专场 | 校外专场 | 大型招聘会 | 综合信息 | 周五双选会 | +| -------- | -------- | ---------- | -------- | ---------- | +| 0 | 1 | 2 | 3 | 4 | + + + ## 江南大学 ### 教务处通知 diff --git a/lib/router.js b/lib/router.js index c970d8392b..547c594b61 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1267,6 +1267,9 @@ router.get('/zju/grs/:type', require('./routes/universities/zju/grs')); router.get('/zju/career/:type', require('./routes/universities/zju/career')); router.get('/zju/cst/:type', require('./routes/universities/zju/cst')); +// 华中师范大学 +router.get('/ccnu/career/:type', require('./routes/universities/ccnu/career')); + // Infoq router.get('/infoq/recommend', require('./routes/infoq/recommend')); router.get('/infoq/topic/:id', require('./routes/infoq/topic')); diff --git a/lib/routes/universities/ccnu/career.js b/lib/routes/universities/ccnu/career.js new file mode 100644 index 0000000000..21caec6379 --- /dev/null +++ b/lib/routes/universities/ccnu/career.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const host = 'http://career.ccnu.edu.cn'; + +const scheduleCatPrefix = 'ScheduleCategory?type='; + +const schedules = ['校内专场', '校外专场', '大型招聘会', '综合信息'].map((x) => new Map([['type', x], ['suffix', `${scheduleCatPrefix}${encodeURIComponent(x)}`]])); +const zwssh = new Map([['type', '周五双选会'], ['suffix', 'ZWSSHList']]); +schedules.push(zwssh); + +module.exports = async (ctx) => { + const id = Number.parseInt(ctx.params.type); + const urlSuffix = schedules[id].get('suffix'); + const response = await got({ + method: 'get', + url: `${host}/Schedule/${urlSuffix}`, + }); + + const $ = cheerio.load(response.data); + const list = $('ul.nlist li'); + + const items = + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('a').text(), + pubDate: new Date(item.find('span').text()).toUTCString(), + link: `${host}${item + .find('a') + .eq(0) + .attr('href')}`, + }; + }) + .get(); + + ctx.state.data = { + title: '华中师范大学就业信息', + link: host, + item: items, + }; +};