feat(route): add 北京邮电大学人才招聘 (#8438)

This commit is contained in:
Ethan Shen
2021-11-27 08:42:45 +00:00
committed by GitHub
parent 3539021c43
commit d24db95f06
5 changed files with 74 additions and 0 deletions
+4
View File
@@ -283,6 +283,10 @@ pageClass: routes
:::
### 人才招聘
<Route author="nczitzk" example="/bupt/rczp" path="/bupt/rczp" />
## 常州大学
### 教务处
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/rczp': ['nczitzk'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'bupt.edu.cn': {
_name: '北京邮电大学',
'.': [
{
title: '人才招聘',
docs: 'https://docs.rsshub.app/university.html#bei-jing-you-dian-da-xue-ren-cai-zhao-pin',
source: ['/'],
target: '/bupt/rczp',
},
],
},
};
+51
View File
@@ -0,0 +1,51 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const rootUrl = 'https://www.bupt.edu.cn';
const currentUrl = `${rootUrl}/rczp.htm`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('.date-block')
.map((_, item) => {
item = $(item);
return {
title: item.next().text(),
link: `${rootUrl}/${item.next().attr('href')}`,
};
})
.get();
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
item.description = content('.v_news_content').html();
item.pubDate = timezone(parseDate(content('.info span').first().text().replace('发布时间 : ', '')), +8);
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/rczp', require('./rczp'));
};