From de4b980a9dea649fa7773c9972efdc23341af426 Mon Sep 17 00:00:00 2001
From: fox2049 <60031998+fox2049@users.noreply.github.com>
Date: Wed, 19 Jul 2023 20:46:50 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20dhu/yjs/news=20=E4=B8=9C?=
=?UTF-8?q?=E5=8D=8E=E5=A4=A7=E5=AD=A6=E7=A0=94=E7=A9=B6=E7=94=9F=E9=99=A2?=
=?UTF-8?q?=E9=80=9A=E7=9F=A5=20(#12831)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* add yjs-news
* add yjs news
* Update news.js
* Update lib/v2/dhu/yjs/news.js
* feat: add radar
---------
---
docs/university.md | 30 ++++++++++++++++---------
lib/v2/dhu/maintainer.js | 1 +
lib/v2/dhu/radar.js | 6 +++++
lib/v2/dhu/router.js | 1 +
lib/v2/dhu/yjs/news.js | 47 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 75 insertions(+), 10 deletions(-)
create mode 100644 lib/v2/dhu/yjs/news.js
diff --git a/docs/university.md b/docs/university.md
index 6fabdcaab..5e6072a3d 100644
--- a/docs/university.md
+++ b/docs/university.md
@@ -619,7 +619,7 @@ pageClass: routes
| 博士研究生 | 硕士研究生 | 同等学力攻读硕士学位 | 港澳台地区招生 |
| :--------: | :--------: | :------------------: | :------------: |
-| bsyjs | ssyjs | tdxlgdssxw | gatdqzs |
+| bsyjs | ssyjs | tdxlgdssxw | gatdqzs |
@@ -1039,6 +1039,16 @@ pageClass: routes
+### 研究生院通知
+
+
+
+| 新闻动态 | 通知公告 | 选课考试 |
+| -------- | -------- | -------- |
+| trend | notice | class |
+
+
+
### 研究生招生信息
@@ -1261,7 +1271,7 @@ category 列表:
| 通知公告 | 新闻动态 | 学籍注册 | 奖助学金 | 其他 |
| :------: | :------: | :------: | :------: | :--: |
-| 2981 | 2980 | 3009 | 3011 | ... |
+| 2981 | 2980 | 3009 | 3011 | ... |
@@ -1293,7 +1303,7 @@ category 列表:
| 新闻 | 新闻 - 要闻 | 新闻 - 专题策划 | 其他 |
| :------: | :---------: | :-------------: | :--: |
-| /card/xw | /list/xw/yw | /card/xw/ztch | ... |
+| /card/xw | /list/xw/yw | /card/xw/ztch | ... |
@@ -1303,7 +1313,7 @@ category 列表:
| 新闻动态 | 通知公告 | 其他 |
| :------: | :------: | :--: |
-| 3751 | 3752 | ... |
+| 3751 | 3752 | ... |
@@ -2380,7 +2390,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 通知公告 | 本科生教务 | 研究生教务 |
| :------: | :--------: | :--------: |
-| tzgg | bksjw | yjsjw |
+| tzgg | bksjw | yjsjw |
@@ -2840,7 +2850,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 聚焦天大 | 综合新闻 | 校内新闻 | 媒体报道 | 图说天大 |
| :------: | :------: | :------: | :------: | :------: |
-| focus | general | internal | media | picture |
+| focus | general | internal | media | picture |
@@ -2850,7 +2860,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 学部新闻 | 通知公告 | 北洋智算论坛 |
| :------: | :----------: | :----------: |
-| news | notification | forum |
+| news | notification | forum |
@@ -2870,7 +2880,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 校级公告 | 统考硕士 | 统考博士 | 在职学位 |
| :------: | :------: | :------: | :------: |
-| notice | master | doctor | job |
+| notice | master | doctor | job |
@@ -2918,7 +2928,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 温大新闻 | 媒体温大 | 学术温大 | 通知公告 | 招标信息 | 学术公告 |
| :------: | :------: | :------: | :------: | :------: | :------: |
-| 0 | 1 | 2 | 3 | 4 | 5 |
+| 0 | 1 | 2 | 3 | 4 | 5 |
@@ -3765,7 +3775,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
| 招聘类型 | 博士后 | 课题项目聘用 | 管理支撑人才 | 教学科研人才 |
| :------: | :----: | :----------: | :----------: | :----------: |
-| 参数 | bsh | ktxmpy | glzcrc | jxkyrc |
+| 参数 | bsh | ktxmpy | glzcrc | jxkyrc |
diff --git a/lib/v2/dhu/maintainer.js b/lib/v2/dhu/maintainer.js
index b754aef4e..6becf4712 100644
--- a/lib/v2/dhu/maintainer.js
+++ b/lib/v2/dhu/maintainer.js
@@ -2,5 +2,6 @@ module.exports = {
'/jiaowu/news/:type?': ['KiraKiseki'],
'/news/xsxx': ['fox2049'],
'/xxgk/news': ['KiraKiseki'],
+ '/yjs/news/:type?': ['fox2049'],
'/yjs/zs/:type?': ['fox2049'],
};
diff --git a/lib/v2/dhu/radar.js b/lib/v2/dhu/radar.js
index a07a40b43..c28d293b1 100644
--- a/lib/v2/dhu/radar.js
+++ b/lib/v2/dhu/radar.js
@@ -1,6 +1,12 @@
module.exports = {
'dhu.edu.cn': {
_name: '东华大学',
+ gs: [
+ {
+ title: '研究生院通知',
+ docs: 'https://docs.rsshub.app/university.html#dong-hua-da-xue',
+ },
+ ],
jw: [
{
title: '教务处通知',
diff --git a/lib/v2/dhu/router.js b/lib/v2/dhu/router.js
index 1bf575a24..d97253def 100644
--- a/lib/v2/dhu/router.js
+++ b/lib/v2/dhu/router.js
@@ -2,5 +2,6 @@ module.exports = function (router) {
router.get('/jiaowu/news/:type?', require('./jiaowu/news'));
router.get('/news/xsxx', require('./news/xsxx'));
router.get('/xxgk/news', require('./xxgk/news'));
+ router.get('/yjs/news/:type?', require('./yjs/news'));
router.get('/yjs/zs/:type?', require('./yjs/zs'));
};
diff --git a/lib/v2/dhu/yjs/news.js b/lib/v2/dhu/yjs/news.js
new file mode 100644
index 000000000..2a7ff583b
--- /dev/null
+++ b/lib/v2/dhu/yjs/news.js
@@ -0,0 +1,47 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { parseDate } = require('@/utils/parse-date');
+
+const baseUrl = 'https://gs.dhu.edu.cn';
+
+const map = {
+ trend: '/7205/list.htm',
+ notice: '/7206/list.htm',
+ class: '/xkks/list.htm',
+};
+module.exports = async (ctx) => {
+ const type = ctx.params.type || 'class';
+ const link = `${baseUrl}${map[type]}`;
+ const { data: response } = await got(link);
+
+ const $ = cheerio.load(response);
+ const list = $('.sub_list > li')
+ .toArray()
+ .map((item) => {
+ item = $(item);
+ const a = item.find('a').first();
+ return {
+ title: a.attr('title'),
+ link: a.attr('href').startsWith('http') ? a.attr('href') : `${baseUrl}${a.attr('href')}`,
+ pubDate: parseDate(item.find('span').text()),
+ };
+ });
+
+ // 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: '东华大学研究生-' + $('.Column_Name').text(),
+ link,
+ item: items,
+ };
+};