Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route): add chsi/hotnews #12154

Merged
merged 5 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(route): add chsi/hotnews
  • Loading branch information
牛鑫语 committed Mar 21, 2023
commit d25bff694675b0aff1b337db247ab7c23fac3089
30 changes: 17 additions & 13 deletions docs/study.md
Original file line number Diff line number Diff line change
Expand Up @@ -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> 的返回结果为准

Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -564,9 +564,9 @@ path="/ctfhub/upcoming/:limit?"

:::

| 每周收藏排行榜・TOP5 | 每周热门「读书笔记」榜 TOP5 | 【印象话题】选择的悖论 | 【印象专题】如何一秒洞察问题本质? | 「识堂开讲」5 位嘉宾精华笔记大放送 | 【印象话题】培养专注力的 5 个步骤 | 🎁购物清单主题活动获奖结果 |
| -------------------- | --------------------------- | ---------------------- | ---------------------------------- | ---------------------------------- | --------------------------------- | -------------------------- |
| 32 | 33 | 101 | 103 | 104 | 105 | 106 |
| 每周收藏排行榜・TOP5 | 每周热门「读书笔记」榜 TOP5 | 【印象话题】选择的悖论 | 【印象专题】如何一秒洞察问题本质? | 「识堂开讲」5 位嘉宾精华笔记大放送 | 【印象话题】培养专注力的 5 个步骤 | 🎁 购物清单主题活动获奖结果 |
| -------------------- | --------------------------- | ---------------------- | ---------------------------------- | ---------------------------------- | --------------------------------- | --------------------------- |
| 32 | 33 | 101 | 103 | 104 | 105 | 106 |

</Route>

Expand Down Expand Up @@ -703,6 +703,10 @@ path="/ctfhub/upcoming/:limit?"

<Route author="SunBK201" example="/chsi/kydt" path="/chsi/kydt" radar="1" />

### 考研热点新闻

<Route author="yanbot-team" example="/chsi/hotnews" path="/chsi/hotnews" radar="1" />

## 中国智库网

### 观点与实践
Expand Down
47 changes: 47 additions & 0 deletions lib/v2/chsi/hotnews.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');

const host = 'https://yz.chsi.com.cn';

module.exports = async (ctx) => {
const response = await got(host);
const $ = cheerio.load(response.data);
const list = $('.focus-part .index-hot a');
const items = await Promise.all(
list.map((i, item) => {
const { href: path, title: itemTitle } = item.attribs;
let itemUrl = '';
if (!path.startsWith('https://') && !path.startsWith('http://')) {
itemUrl = host + path;
} else {
itemUrl = path;
}
return ctx.cache.tryGet(itemUrl, async () => {
let description = '';
if (!path.startsWith('https://') && !path.startsWith('http://')) {
niuyi1017 marked this conversation as resolved.
Show resolved Hide resolved
const result = await got(itemUrl);
const $ = cheerio.load(result.data);
if ($('#article_dnull').html()) {
description = $('#article_dnull').html().trim();
} else {
niuyi1017 marked this conversation as resolved.
Show resolved Hide resolved
description = itemTitle;
}
} else {
description = itemTitle;
}
return {
title: itemTitle,
link: itemUrl,
description,
};
});
})
);

ctx.state.data = {
title: `中国研究生招生信息网 - 热点`,
link: String(host),
niuyi1017 marked this conversation as resolved.
Show resolved Hide resolved
description: '中国研究生招生信息网 - 热点',
item: items,
};
};
1 change: 1 addition & 0 deletions lib/v2/chsi/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
'/kydt': ['SunBK201'],
'/hotnews': ['yanbot-team'],
niuyi1017 marked this conversation as resolved.
Show resolved Hide resolved
};
6 changes: 6 additions & 0 deletions lib/v2/chsi/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ module.exports = {
source: ['/kyzx/kydt'],
target: '/chsi/kydt',
},
{
title: '考研热点新闻',
docs: 'https://docs.rsshub.app/study.html#zhong-guo-yan-jiu-sheng-zhao-sheng-xin-xi-wang',
source: ['/'],
target: '/chsi/hotnews',
},
],
},
};
1 change: 1 addition & 0 deletions lib/v2/chsi/router.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = (router) => {
router.get('/kydt', require('./kydt'));
router.get('/hotnews', require('./hotnews'));
niuyi1017 marked this conversation as resolved.
Show resolved Hide resolved
};