feat(route): add 中南财经政法大学通知公告 (#9616)

This commit is contained in:
Ethan Shen
2022-04-25 20:56:47 +08:00
committed by GitHub
parent 68b2499d4a
commit bc92dbcdc2
5 changed files with 77 additions and 0 deletions
+6
View File
@@ -3120,6 +3120,12 @@ type 列表:
<Route author="sushengmao" example="/zkyai" path="/zkyai" />
## 中南财经政法大学
### 通知公告
<Route author="nczitzk" example="/zuel/notice" path="/zuel/notice"/>
## 中南大学
### 招聘信息
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/notice': ['nczitzk'],
};
+52
View File
@@ -0,0 +1,52 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const rootUrl = 'http://wap.zuel.edu.cn';
const currentUrl = `${rootUrl}/notice/list.htm`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
let items = $('.list_item')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('.Article_Title a');
return {
title: a.text(),
pubDate: parseDate(item.find('.Article_PublishDate').text()),
link: `${/^http/.test(a.attr('href')) ? '' : rootUrl}${a.attr('href')}`,
};
});
items = await Promise.all(
items.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('.wp_articlecontent, .psgCont, .infodetail').html();
return item;
})
)
);
ctx.state.data = {
title: '中南财经大学 - 通知公告',
link: currentUrl,
item: items,
};
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'zuel.edu.cn': {
_name: '中南财经政法大学',
wap: [
{
title: '通知公告',
docs: 'https://docs.rsshub.app/univeristy.html#zhong-nan-cai-jing-zheng-fa-da-xue-tong-zhi-gong-gao',
source: ['/', '/notice/list.htm'],
target: '/zuel/notice',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/notice', require('./notice'));
};