mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-12 16:20:27 +08:00
feat(route): add 西安交大就业服务中心路由 (#7783)
This commit is contained in:
@@ -1922,6 +1922,16 @@ type 列表:
|
|||||||
|
|
||||||
<Route author="nczitzk" example="/xjtu/gs/tzgg" path="/xjtu/gs/tzgg" />
|
<Route author="nczitzk" example="/xjtu/gs/tzgg" path="/xjtu/gs/tzgg" />
|
||||||
|
|
||||||
|
### 就业创业中心
|
||||||
|
|
||||||
|
<Route author="DylanXie123" example="/xjtu/job/xdsgwy" path="/xjtu/job/:subpath?" :paramsDesc="['栏目类型,默认请求`zxtg`,详见下方表格']" />
|
||||||
|
|
||||||
|
栏目类型
|
||||||
|
|
||||||
|
| 中心通告 | 选调生及公务员 | 国际组织实习 | 新闻资讯 | 活动与讲座 |
|
||||||
|
| -------- | -------------- | ------------ | -------- | ---------- |
|
||||||
|
| zxtg | xdsgwy | gjzzsx | xwzx | hdyjz |
|
||||||
|
|
||||||
## 西北工业大学
|
## 西北工业大学
|
||||||
|
|
||||||
### 翱翔门户
|
### 翱翔门户
|
||||||
|
|||||||
@@ -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/gs/tzgg', require('./routes/universities/xjtu/gs/tzgg'));
|
||||||
router.get('/xjtu/dean/:subpath+', require('./routes/universities/xjtu/dean'));
|
router.get('/xjtu/dean/:subpath+', require('./routes/universities/xjtu/dean'));
|
||||||
router.get('/xjtu/international/:subpath+', require('./routes/universities/xjtu/international'));
|
router.get('/xjtu/international/:subpath+', require('./routes/universities/xjtu/international'));
|
||||||
|
router.get('/xjtu/job/:subpath?', require('./routes/universities/xjtu/job'));
|
||||||
|
|
||||||
// booksource
|
// booksource
|
||||||
router.get('/booksource', require('./routes/booksource/index'));
|
router.get('/booksource', require('./routes/booksource/index'));
|
||||||
|
|||||||
51
lib/routes/universities/xjtu/job.js
Normal file
51
lib/routes/universities/xjtu/job.js
Normal file
@@ -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;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user