feat: 添加华中师范大学就业信息 (#3257)
This commit is contained in:
@@ -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'));
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user