feat: 添加华中师范大学就业信息 (#3257)

This commit is contained in:
Jack Yu
2019-10-18 11:48:14 +08:00
committed by DIYgod
parent 3015412b23
commit 2d985cfa84
3 changed files with 58 additions and 0 deletions

View File

@@ -410,6 +410,18 @@ category 列表:
<Route author="RayHY" example="/hust/aia/news" path="/universities/hust/aia/news" /> <Route author="RayHY" example="/hust/aia/news" path="/universities/hust/aia/news" />
## 华中师范大学
### 就业信息
<Route author="jackyu1996" example="/ccnu/career/0" path="/universities/ccnu/career/:type" :paramsDesc="['对应以下不同类别']">
| 校内专场 | 校外专场 | 大型招聘会 | 综合信息 | 周五双选会 |
| -------- | -------- | ---------- | -------- | ---------- |
| 0 | 1 | 2 | 3 | 4 |
</Route>
## 江南大学 ## 江南大学
### 教务处通知 ### 教务处通知

View File

@@ -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/career/:type', require('./routes/universities/zju/career'));
router.get('/zju/cst/:type', require('./routes/universities/zju/cst')); router.get('/zju/cst/:type', require('./routes/universities/zju/cst'));
// 华中师范大学
router.get('/ccnu/career/:type', require('./routes/universities/ccnu/career'));
// Infoq // Infoq
router.get('/infoq/recommend', require('./routes/infoq/recommend')); router.get('/infoq/recommend', require('./routes/infoq/recommend'));
router.get('/infoq/topic/:id', require('./routes/infoq/topic')); router.get('/infoq/topic/:id', require('./routes/infoq/topic'));

View File

@@ -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,
};
};