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:
fox2049
2023-06-05 23:34:01 +08:00
committed by GitHub
co-authored by Yuexin Sun
parent 7eed69380d
commit 28aa9e6703
5 changed files with 50 additions and 0 deletions
+10
View File
@@ -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
View File
@@ -1,4 +1,5 @@
module.exports = {
'/jiaowu/news/:type?': ['KiraKiseki'],
'/xxgk/news': ['KiraKiseki'],
'/yjs/zs/:type?': ['fox2049'],
};
+6
View File
@@ -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
View File
@@ -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'));
};
+32
View File
@@ -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,
};
};