feat(router): add 东华大学研究生招生信息 (dhu/yjs/zs) (#12596)
* add yjszs info of dhu * change order and add zs make * 4 spaces for indentation, camelCase, del utf-8 decoder, link to string * code proofreading * delete got params * update link code * delete link body in ctx.state.data * Update lib/v2/dhu/maintainer.js --------- Co-authored-by: Yuexin Sun <m090120303@outlook.com>
This commit is contained in:
@@ -1011,6 +1011,16 @@ pageClass: routes
|
||||
|
||||
<Route author="KiraKiseki" example="/dhu/xxgk/news" path="/dhu/xxgk/news"/>
|
||||
|
||||
### 研究生招生信息
|
||||
|
||||
<Route author="fox2049" example="/dhu/yjs/zs" path="/dhu/yjs/zs/:type?" :paramsDesc="['默认为 `master`']">
|
||||
|
||||
| 博士招生 | 硕士招生 |
|
||||
| -------- | -------- |
|
||||
| doctor | master |
|
||||
|
||||
</Route>
|
||||
|
||||
## 东南大学
|
||||
|
||||
### 信息科学与工程学院学术活动
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
module.exports = {
|
||||
'/jiaowu/news/:type?': ['KiraKiseki'],
|
||||
'/xxgk/news': ['KiraKiseki'],
|
||||
'/yjs/zs/:type?': ['fox2049'],
|
||||
};
|
||||
|
||||
@@ -13,5 +13,11 @@ module.exports = {
|
||||
docs: 'https://docs.rsshub.app/university.html#dong-hua-da-xue',
|
||||
},
|
||||
],
|
||||
yjs: [
|
||||
{
|
||||
title: '研究生信息',
|
||||
docs: 'https://docs.rsshub.app/university.html#dong-hua-da-xue',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/jiaowu/news/:type?', require('./jiaowu/news'));
|
||||
router.get('/xxgk/news', require('./xxgk/news'));
|
||||
router.get('/yjs/zs/:type?', require('./yjs/zs'));
|
||||
};
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timeZone = require('@/utils/timezone');
|
||||
|
||||
const baseUrl = 'https://yjszs.dhu.edu.cn';
|
||||
|
||||
const map = {
|
||||
doctor: '/7126/list.htm',
|
||||
master: '/7128/list.htm',
|
||||
};
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type || 'master';
|
||||
const link = `${baseUrl}${map[type]}`;
|
||||
const { data: response } = await got(link);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const items = $('.list_item')
|
||||
.map((_, elem) => ({
|
||||
link: new URL($('a', elem).attr('href'), baseUrl).href,
|
||||
title: $('a', elem).attr('title'),
|
||||
pubDate: timeZone(parseDate($('.Article_PublishDate', elem).text()), +8),
|
||||
}))
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '东华大学研究生-' + $('.col_title').text(),
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user