feat(router): add link content of dhu/yjs/zs (#12627)

* 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

* code proofreading
* example update
* html parse update

* add content

* delete comments

* delete comments

* update code from remote

* add link content

* link update

---------

Co-authored-by: Yuexin Sun <m090120303@outlook.com>
This commit is contained in:
fox2049 2023-06-07 20:16:00 +08:00 committed by GitHub
parent 89e66ea39c
commit 9d13d768cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 19 deletions

View File

@ -619,7 +619,7 @@ pageClass: routes
| 博士研究生 | 硕士研究生 | 同等学力攻读硕士学位 | 港澳台地区招生 |
| :--------: | :--------: | :------------------: | :------------: |
| bsyjs | ssyjs | tdxlgdssxw | gatdqzs |
| bsyjs | ssyjs | tdxlgdssxw | gatdqzs |
</Route>
@ -1013,7 +1013,7 @@ pageClass: routes
### 研究生招生信息
<Route author="fox2049" example="/dhu/yjs/zs" path="/dhu/yjs/zs/:type?" :paramsDesc="['默认为 `master`']">
<Route author="fox2049" example="/dhu/yjs/zs/master" path="/dhu/yjs/zs/:type?" :paramsDesc="['默认为 `master`']">
| 博士招生 | 硕士招生 |
| -------- | -------- |
@ -1229,7 +1229,7 @@ category 列表:
| 通知公告 | 新闻动态 | 学籍注册 | 奖助学金 | 其他 |
| :------: | :------: | :------: | :------: | :--: |
| 2981 | 2980 | 3009 | 3011 | ... |
| 2981 | 2980 | 3009 | 3011 | ... |
</Route>
@ -1261,7 +1261,7 @@ category 列表:
| 新闻 | 新闻 - 要闻 | 新闻 - 专题策划 | 其他 |
| :------: | :---------: | :-------------: | :--: |
| /card/xw | /list/xw/yw | /card/xw/ztch | ... |
| /card/xw | /list/xw/yw | /card/xw/ztch | ... |
</Route>
@ -1271,7 +1271,7 @@ category 列表:
| 新闻动态 | 通知公告 | 其他 |
| :------: | :------: | :--: |
| 3751 | 3752 | ... |
| 3751 | 3752 | ... |
</Route>
@ -2348,7 +2348,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 通知公告 | 本科生教务 | 研究生教务 |
| :------: | :--------: | :--------: |
| tzgg | bksjw | yjsjw |
| tzgg | bksjw | yjsjw |
</Route>
@ -2796,7 +2796,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 聚焦天大 | 综合新闻 | 校内新闻 | 媒体报道 | 图说天大 |
| :------: | :------: | :------: | :------: | :------: |
| focus | general | internal | media | picture |
| focus | general | internal | media | picture |
</Route>
@ -2806,7 +2806,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 学部新闻 | 通知公告 | 北洋智算论坛 |
| :------: | :----------: | :----------: |
| news | notification | forum |
| news | notification | forum |
</Route>
@ -2826,7 +2826,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 校级公告 | 统考硕士 | 统考博士 | 在职学位 |
| :------: | :------: | :------: | :------: |
| notice | master | doctor | job |
| notice | master | doctor | job |
</Route>
@ -2874,7 +2874,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 温大新闻 | 媒体温大 | 学术温大 | 通知公告 | 招标信息 | 学术公告 |
| :------: | :------: | :------: | :------: | :------: | :------: |
| 0 | 1 | 2 | 3 | 4 | 5 |
| 0 | 1 | 2 | 3 | 4 | 5 |
</Route>
@ -3683,7 +3683,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 招聘类型 | 博士后 | 课题项目聘用 | 管理支撑人才 | 教学科研人才 |
| :------: | :----: | :----------: | :----------: | :----------: |
| 参数 | bsh | ktxmpy | glzcrc | jxkyrc |
| 参数 | bsh | ktxmpy | glzcrc | jxkyrc |
</Route>

View File

@ -1,7 +1,6 @@
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';
@ -15,14 +14,29 @@ module.exports = async (ctx) => {
const { data: response } = await got(link);
const $ = cheerio.load(response);
const list = $('.list_item')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('a').first();
return {
title: a.attr('title'),
link: `${baseUrl}${a.attr('href')}`,
pubDate: parseDate(item.find('.Article_PublishDate').text()),
};
});
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();
// item content
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);
item.description = $('.wp_articlecontent').first().html();
return item;
})
)
);
ctx.state.data = {
title: '东华大学研究生-' + $('.col_title').text(),