From 83523842cde9d6ea8a2e1df9f3a87b84f633c94e Mon Sep 17 00:00:00 2001
From: niuyi <30387148+niuyi1017@users.noreply.github.com>
Date: Fri, 7 Apr 2023 20:39:06 +0800
Subject: [PATCH] feat(route): add sass/gs/sstmzs (#12159)
* feat(route):add sassorgcn/gs/:type
* feat(route):add sassorgcn/gs/:type
* update:sassorgcn docs & radar
* fix: docs add tag in /sassorgcn/gs/:type
* update: sassorgcn docs
* refactor: fix namespace
---------
---
docs/university.md | 12 +++++++++
lib/v2/sass/gs/index.js | 55 +++++++++++++++++++++++++++++++++++++++
lib/v2/sass/maintainer.js | 3 +++
lib/v2/sass/radar.js | 13 +++++++++
lib/v2/sass/router.js | 3 +++
5 files changed, 86 insertions(+)
create mode 100644 lib/v2/sass/gs/index.js
create mode 100644 lib/v2/sass/maintainer.js
create mode 100644 lib/v2/sass/radar.js
create mode 100644 lib/v2/sass/router.js
diff --git a/docs/university.md b/docs/university.md
index 1115eafceb..8676a20276 100644
--- a/docs/university.md
+++ b/docs/university.md
@@ -2558,6 +2558,18 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
+## 上海社会科学院
+
+### 研究生院
+
+
+
+| 硕士统考招生 | 硕士推免招生 |
+| ------------ | ------------ |
+| 1793 | sstmzs |
+
+
+
## 深圳大学
### 深圳大学研究生招生网通知公告
diff --git a/lib/v2/sass/gs/index.js b/lib/v2/sass/gs/index.js
new file mode 100644
index 0000000000..522294dbc3
--- /dev/null
+++ b/lib/v2/sass/gs/index.js
@@ -0,0 +1,55 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { parseDate } = require('@/utils/parse-date');
+
+const host = 'https://gs.sass.org.cn';
+module.exports = async (ctx) => {
+ const type = ctx.params.type;
+ const url = `${host}/${type}/list.htm`;
+
+ const response = await got(url);
+
+ const $ = cheerio.load(response.data);
+ const list = $('.column-news-list .cols_list .cols');
+ const items = await Promise.all(
+ list.map((i, item) => {
+ const [titleLink, time] = item.children;
+ const itemDate = $(time).text();
+ const { href: path, title: itemTitle } = titleLink.children[0].attribs;
+
+ let itemUrl = '';
+ if (path.startsWith('http')) {
+ itemUrl = path;
+ } else {
+ itemUrl = host + path;
+ }
+ return ctx.cache.tryGet(itemUrl, async () => {
+ let description = '';
+ if (itemUrl) {
+ const result = await got(itemUrl);
+ const $ = cheerio.load(result.data);
+ if ($('.read .wp_articlecontent').length) {
+ description = $('.read .wp_articlecontent').html().trim();
+ } else {
+ description = itemTitle;
+ }
+ } else {
+ description = itemTitle;
+ }
+ return {
+ title: itemTitle,
+ link: itemUrl,
+ description,
+ pubDate: parseDate(itemDate, 'YYYY-MM-DD'),
+ };
+ });
+ })
+ );
+ // 处理返回
+ ctx.state.data = {
+ title: '上海社会科学院 - 研究生院',
+ link: url,
+ description: '上海社会科学院 - 研究生院',
+ item: items,
+ };
+};
diff --git a/lib/v2/sass/maintainer.js b/lib/v2/sass/maintainer.js
new file mode 100644
index 0000000000..d8ff00d51e
--- /dev/null
+++ b/lib/v2/sass/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/gs/:type': ['yanbot-team'],
+};
diff --git a/lib/v2/sass/radar.js b/lib/v2/sass/radar.js
new file mode 100644
index 0000000000..905d930ea9
--- /dev/null
+++ b/lib/v2/sass/radar.js
@@ -0,0 +1,13 @@
+module.exports = {
+ 'sass.org.cn': {
+ _name: '上海社会科学院',
+ gs: [
+ {
+ title: '研究生院',
+ docs: 'https://docs.rsshub.app/university.html#shang-hai-she-hui-ke-xue-yuan-yan-jiu-sheng-yuan',
+ source: ['/:type/list.htm'],
+ target: '/sass/gs/:type',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/sass/router.js b/lib/v2/sass/router.js
new file mode 100644
index 0000000000..7c655c8461
--- /dev/null
+++ b/lib/v2/sass/router.js
@@ -0,0 +1,3 @@
+module.exports = (router) => {
+ router.get('/gs/:type', require('./gs/index'));
+};