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 </Route> tag in /sassorgcn/gs/:type

* update: sassorgcn docs

* refactor: fix namespace

---------
This commit is contained in:
niuyi
2023-04-07 20:39:06 +08:00
committed by GitHub
parent c121ba30fa
commit 83523842cd
5 changed files with 86 additions and 0 deletions

View File

@@ -2558,6 +2558,18 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
<Route author="NeverBehave" example="/slu/tyyjkxy/14754" path="/slu/tyyjkxy/:id" :paramsDesc="['类别ID']" />
## 上海社会科学院
### 研究生院
<Route author="yanbot-team" example="/sass/gs/1793" path="/sass/gs/:type" :paramsDesc="['类别 ID见下表其他未列出的栏目参数可以从页面的 URL Path 中找到,例如:硕士统考招生的网址为 `https://gs.sass.org.cn/1793/list.htm`,则类别 ID 为`1793`']" radar="1" >
| 硕士统考招生 | 硕士推免招生 |
| ------------ | ------------ |
| 1793 | sstmzs |
</Route>
## 深圳大学
### 深圳大学研究生招生网通知公告

55
lib/v2/sass/gs/index.js Normal file
View File

@@ -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,
};
};

View File

@@ -0,0 +1,3 @@
module.exports = {
'/gs/:type': ['yanbot-team'],
};

13
lib/v2/sass/radar.js Normal file
View File

@@ -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',
},
],
},
};

3
lib/v2/sass/router.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/gs/:type', require('./gs/index'));
};