diff --git a/docs/university.md b/docs/university.md index 227cd9a9cc..105c090c57 100644 --- a/docs/university.md +++ b/docs/university.md @@ -1922,6 +1922,16 @@ type 列表: +### 就业创业中心 + + + +栏目类型 + +| 中心通告 | 选调生及公务员 | 国际组织实习 | 新闻资讯 | 活动与讲座 | +| -------- | -------------- | ------------ | -------- | ---------- | +| zxtg | xdsgwy | gjzzsx | xwzx | hdyjz | + ## 西北工业大学 ### 翱翔门户 diff --git a/lib/router.js b/lib/router.js index 54aea88868..3bd79ed398 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2651,6 +2651,7 @@ router.get('/wolley/host/:host', require('./routes/wolley/host')); router.get('/xjtu/gs/tzgg', require('./routes/universities/xjtu/gs/tzgg')); router.get('/xjtu/dean/:subpath+', require('./routes/universities/xjtu/dean')); router.get('/xjtu/international/:subpath+', require('./routes/universities/xjtu/international')); +router.get('/xjtu/job/:subpath?', require('./routes/universities/xjtu/job')); // booksource router.get('/booksource', require('./routes/booksource/index')); diff --git a/lib/routes/universities/xjtu/job.js b/lib/routes/universities/xjtu/job.js new file mode 100644 index 0000000000..ce2da33838 --- /dev/null +++ b/lib/routes/universities/xjtu/job.js @@ -0,0 +1,51 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const subpath = ctx.params.subpath || 'zxtg'; + const arr = { + zxtg: '中心通告', + xdsgwy: '选调生|公务员', + gjzzsx: '国际组织实习', + xwzx: '新闻资讯', + hdyjz: '活动与讲座', + }; + const rootUrl = `https://job.xjtu.edu.cn/news.do;?ext=${arr[subpath]}`; + const baseUrl = 'https://job.xjtu.edu.cn'; + + const list_response = await got.get(rootUrl); + const $ = cheerio.load(list_response.data); + + const list = $('div.jsnr ul li') + .slice(0, 10) + .map((_, item) => { + item = $(item); + const a = item.find('a'); + return { + title: a.find('span').text(), + link: new URL(a.attr('href'), baseUrl), + }; + }) + .get(); + + ctx.state.data = { + title: `西安交通大学就业网-${arr[subpath]}`, + link: baseUrl, + item: await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const res = await got.get(item.link); + const content = cheerio.load(res.data); + item.description = content('div.jsnr').html(); + const dateStr = content('div.jsnrly span').eq(1).text(); + const date = parseDate(dateStr, 'YYYY MM DD HH mm', 'zh-cn'); + item.pubDate = timezone(date, +8); + return item; + }) + ) + ), + }; +};