From 5373b5878b2fcca2fc15431aaa70bcb41e94eccb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=99=BD?= <39430235+3401797899@users.noreply.github.com>
Date: Fri, 28 Jul 2023 20:59:58 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=B8=AD=E5=9B=BD?=
=?UTF-8?q?=E6=B5=B7=E6=B4=8B=E5=A4=A7=E5=AD=A6=E9=80=89=E8=AF=BE=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E6=95=99=E5=8A=A1=E9=80=9A=E7=9F=A5=20(#12880)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(route): add 中国海洋大学教务处
* fix: sort entries
* fix: 修复错误的entries排序
* feat(route): add 中国海洋大学选课信息教务通知
* add selfhost
---------
---
docs/university.md | 7 +++++++
lib/v2/ouc/jwgl.js | 42 ++++++++++++++++++++++++++++++++++++++++
lib/v2/ouc/maintainer.js | 1 +
lib/v2/ouc/radar.js | 24 +++++++++++++++--------
lib/v2/ouc/router.js | 1 +
5 files changed, 67 insertions(+), 8 deletions(-)
create mode 100644 lib/v2/ouc/jwgl.js
diff --git a/docs/university.md b/docs/university.md
index c676883c0..90f61d3c1 100644
--- a/docs/university.md
+++ b/docs/university.md
@@ -3669,6 +3669,13 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
+### 选课信息教务通知
+
+
+::: warning 注意
+由于选课通知仅允许校园网访问,需自行部署。
+:::
+
## 中国科学技术大学
### 官网通知公告
diff --git a/lib/v2/ouc/jwgl.js b/lib/v2/ouc/jwgl.js
new file mode 100644
index 000000000..6f2a88262
--- /dev/null
+++ b/lib/v2/ouc/jwgl.js
@@ -0,0 +1,42 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { parseDate } = require('@/utils/parse-date');
+
+module.exports = async (ctx) => {
+ const link = 'http://jwgl.ouc.edu.cn/public/listSchoolNotices.action?currentPage=1&recordsPerPage=15&qtitle=';
+ const response = await got(link);
+ const $ = cheerio.load(response.data);
+ const list = $('div.datalist table tbody tr')
+ .toArray()
+ .map((e) => {
+ e = $(e);
+ const noticeId = e
+ .find('a')
+ .attr('onclick')
+ .match(/viewNotice\('(.+?)'\)/)[1];
+ const tds = e.find('td');
+ return {
+ title: tds.eq(2).text(),
+ link: 'http://jwgl.ouc.edu.cn/public/viewSchoolNoticeDetail.action?schoolNoticeId=' + noticeId,
+ pubDate: parseDate(tds.eq(3).text(), 'YYYY-MM-DD HH:mm'),
+ };
+ });
+
+ const out = await Promise.all(
+ list.map((item) =>
+ ctx.cache.tryGet(item.link, async () => {
+ const response = await got(item.link);
+ const $ = cheerio.load(response.data);
+ item.description = $('div.notice').html();
+ return item;
+ })
+ )
+ );
+
+ ctx.state.data = {
+ title: '中国海洋大学选课信息教务通知',
+ link,
+ description: '中国海洋大学选课信息教务通知',
+ item: out,
+ };
+};
diff --git a/lib/v2/ouc/maintainer.js b/lib/v2/ouc/maintainer.js
index dc547d772..7cb365c2b 100644
--- a/lib/v2/ouc/maintainer.js
+++ b/lib/v2/ouc/maintainer.js
@@ -2,5 +2,6 @@ module.exports = {
'/it/postgraduate': ['shengmaosu'],
'/it/:type?': ['GeoffreyChen777'],
'/jwc': ['3401797899'],
+ '/jwgl': ['3401797899'],
'/yjs': ['shengmaosu'],
};
diff --git a/lib/v2/ouc/radar.js b/lib/v2/ouc/radar.js
index 6399cbc26..5b5a6e6cb 100644
--- a/lib/v2/ouc/radar.js
+++ b/lib/v2/ouc/radar.js
@@ -1,14 +1,6 @@
module.exports = {
'ouc.edu.cn': {
_name: '中国海洋大学',
- jwc: [
- {
- title: '教务处',
- docs: 'https://docs.rsshub.app/university.html#zhong-guo-hai-yang-da-xue',
- source: ['/', '/6517/list.htm'],
- target: '/ouc/jwc',
- },
- ],
it: [
{
title: '信息科学与工程学院',
@@ -23,6 +15,22 @@ module.exports = {
target: '/ouc/it/postgraduate',
},
],
+ jwc: [
+ {
+ title: '教务处',
+ docs: 'https://docs.rsshub.app/university.html#zhong-guo-hai-yang-da-xue',
+ source: ['/', '/6517/list.htm'],
+ target: '/ouc/jwc',
+ },
+ ],
+ jwgl: [
+ {
+ title: '选课信息教务通知',
+ docs: 'https://docs.rsshub.app/university.html#zhong-guo-hai-yang-da-xue',
+ source: ['/cas/login.action', '/public/SchoolNotice.jsp'],
+ target: '/ouc/jwgl',
+ },
+ ],
yz: [
{
title: '研究生院',
diff --git a/lib/v2/ouc/router.js b/lib/v2/ouc/router.js
index 96f4ae329..5ca322591 100644
--- a/lib/v2/ouc/router.js
+++ b/lib/v2/ouc/router.js
@@ -2,5 +2,6 @@ module.exports = (router) => {
router.get('/it/postgraduate', require('./it-postgraduate'));
router.get('/it/:type?', require('./it'));
router.get('/jwc', require('./jwc'));
+ router.get('/jwgl', require('./jwgl'));
router.get('/yjs', require('./yjs'));
};