feat(route): add /chsi/kyzx/:type (#12164)

* feat(route): add /chsi/kyzx/:type

* Update lib/v2/chsi/kyzx.js

* Update docs/study.md
---------
This commit is contained in:
niuyi
2023-03-24 21:10:04 +08:00
committed by GitHub
parent 82deac591e
commit ba696dfdef
5 changed files with 88 additions and 15 deletions
+26 -12
View File
@@ -61,12 +61,12 @@ path="/ctfhub/search/:limit?/:form?/:class?/:title?"
| `:class` | 类型 |
| :------: | --------------------------------- |
| 0 | Jeopardy [解题] |
| 1 | Attack with Defense [AwD 攻防] |
| 2 | Robo Hacking Game [RHG AI 自动化] |
| 3 | Real World [RW 真实世界] |
| 4 | King of The Hill [KoH 抢占山头] |
| 5 | Mix [混合] |
| 0 | Jeopardy [解题] |
| 1 | Attack with Defense [AwD 攻防] |
| 2 | Robo Hacking Game [RHG AI 自动化] |
| 3 | Real World [RW 真实世界] |
| 4 | King of The Hill [KoH 抢占山头] |
| 5 | Mix [混合] |
> class 以 <https://api.ctfhub.com/User_API/Event/getType> 的返回结果为准
@@ -128,8 +128,8 @@ path="/ctfhub/upcoming/:limit?"
<Route author="nczitzk" example="/mind42/tag/online" path="/mind42/tag/:id" :paramsDesc="['标签,见下表']">
| in | online | cleaning | buy | best | services | for | carpet | service | india | company | and | de | mapa | control | malware | online-dating-website-reviews | virus | international-online-dating-sites-review | repair |
| -- | ------ | -------- | --- | ---- | -------- | --- | ------ | ------- | ----- | ------- | --- | -- | ---- | ------- | ------- | ----------------------------- | ----- | ---------------------------------------- | ------ |
| in | online | cleaning | buy | best | services | for | carpet | service | india | company | and | de | mapa | control | malware | online-dating-website-reviews | virus | international-online-dating-sites-review | repair |
| --- | ------ | -------- | --- | ---- | -------- | --- | ------ | ------- | ----- | ------- | --- | --- | ---- | ------- | ------- | ----------------------------- | ----- | ---------------------------------------- | ------ |
</Route>
@@ -274,9 +274,9 @@ path="/ctfhub/upcoming/:limit?"
<Route author="zytomorrow" example="/dykszx/news" path="/dykszx/news/:type?" :paramsDesc="['考试类型']">
| 新闻中心 | 公务员考试 | 事业单位 | (职)业资格、职称考试 | 其他 |
| 新闻中心 | 公务员考试 | 事业单位 | (职)业资格、职称考试 | 其他 |
| :------: | :--------: | :------: | :--------------------: | :---: |
| all | gwy | sydw | zyzc | other |
| all | gwy | sydw | zyzc | other |
</Route>
@@ -699,13 +699,27 @@ path="/ctfhub/upcoming/:limit?"
## 中国研究生招生信息网
### 考研热点新闻
<Route author="yanbot-team" example="/chsi/hotnews" path="/chsi/hotnews" radar="1" />
### 考研动态
<Route author="SunBK201" example="/chsi/kydt" path="/chsi/kydt" radar="1" />
### 考研热点新闻
### 考研资讯
<Route author="yanbot-team" example="/chsi/hotnews" path="/chsi/hotnews" radar="1" />
<Route author="yanbot-team" example="/chsi/kyzx/fstj" path="/chsi/kyzx/:type" radar="1" :paramsDesc="[' type 见下表,亦可在网站 URL 找到']" >
| `:type` | 专题名称 |
| ------- | -------- |
| fstj | 复试调剂 |
| kydt | 考研动态 |
| zcdh | 政策导航 |
| kyrw | 考研人物 |
| jyxd | 经验心得 |
</Route>
## 中国智库网
+51
View File
@@ -0,0 +1,51 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const host = 'https://yz.chsi.com.cn';
module.exports = async (ctx) => {
const { type } = ctx.request.params;
const response = await got(`${host}/kyzx/${type}`);
const $ = cheerio.load(response.data);
const typeName = $('.bread-nav .location a').last().text() || '考研资讯';
const list = $('ul.news-list').children();
const items = await Promise.all(
list.map((i, item) => {
item = $(item);
const itemTitle = item.find('a').text();
const itemDate = item.find('.span-time').text();
const path = item.find('a').attr('href');
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);
description = $('#article_dnull').html().trim();
} else {
description = itemTitle;
}
return {
title: itemTitle,
link: itemUrl,
pubDate: timezone(parseDate(itemDate), 8),
description,
};
});
})
);
ctx.state.data = {
title: `中国研究生招生信息网 - ${typeName}`,
link: `${host}/kyzx/${type}/`,
description: `中国研究生招生信息网 - ${typeName}`,
item: items,
};
};
+1
View File
@@ -1,4 +1,5 @@
module.exports = {
'/hotnews': ['yanbot-team'],
'/kydt': ['SunBK201'],
'/kyzx/:type': ['yanbot-team'],
};
+9 -3
View File
@@ -2,6 +2,12 @@ module.exports = {
'chsi.com.cn': {
_name: '中国研究生招生信息网',
yz: [
{
title: '考研热点新闻',
docs: 'https://docs.rsshub.app/study.html#zhong-guo-yan-jiu-sheng-zhao-sheng-xin-xi-wang',
source: ['/'],
target: '/chsi/hotnews',
},
{
title: '考研动态',
docs: 'https://docs.rsshub.app/study.html#zhong-guo-yan-jiu-sheng-zhao-sheng-xin-xi-wang',
@@ -9,10 +15,10 @@ module.exports = {
target: '/chsi/kydt',
},
{
title: '考研热点新闻',
title: '考研资讯',
docs: 'https://docs.rsshub.app/study.html#zhong-guo-yan-jiu-sheng-zhao-sheng-xin-xi-wang',
source: ['/'],
target: '/chsi/hotnews',
source: ['/kyzx/:type'],
target: '/chsi/kyzx/:type',
},
],
},
+1
View File
@@ -1,4 +1,5 @@
module.exports = (router) => {
router.get('/hotnews', require('./hotnews'));
router.get('/kydt', require('./kydt'));
router.get('/kyzx/:type', require('./kyzx'));
};