diff --git a/docs/study.md b/docs/study.md index 027defe0c..1ad1f4b1e 100644 --- a/docs/study.md +++ b/docs/study.md @@ -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 以 的返回结果为准 @@ -128,8 +128,8 @@ path="/ctfhub/upcoming/:limit?" -| 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 | +| --- | ------ | -------- | --- | ---- | -------- | --- | ------ | ------- | ----- | ------- | --- | --- | ---- | ------- | ------- | ----------------------------- | ----- | ---------------------------------------- | ------ | @@ -274,9 +274,9 @@ path="/ctfhub/upcoming/:limit?" -| 新闻中心 | 公务员考试 | 事业单位 | (职)业资格、职称考试 | 其他 | +| 新闻中心 | 公务员考试 | 事业单位 | (职)业资格、职称考试 | 其他 | | :------: | :--------: | :------: | :--------------------: | :---: | -| all | gwy | sydw | zyzc | other | +| all | gwy | sydw | zyzc | other | @@ -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 | @@ -703,6 +703,10 @@ path="/ctfhub/upcoming/:limit?" +### 考研热点新闻 + + + ## 中国智库网 ### 观点与实践 diff --git a/lib/v2/chsi/hotnews.js b/lib/v2/chsi/hotnews.js new file mode 100644 index 000000000..5f2c2e4f4 --- /dev/null +++ b/lib/v2/chsi/hotnews.js @@ -0,0 +1,56 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +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('http')) { + itemUrl = path; + } else { + itemUrl = host + path; + } + return ctx.cache.tryGet(itemUrl, async () => { + let description = ''; + let itemDate = undefined; + if (path) { + const result = await got(itemUrl); + const $ = cheerio.load(result.data); + if ($('#article_dnull').html()) { + description = $('#article_dnull').html().trim(); + } else { + description = itemTitle; + } + if ($('.news-time').text()) { + itemDate = $('.news-time').text(); + } + } else { + description = itemTitle; + } + const result = { + title: itemTitle, + link: itemUrl, + description, + }; + if (itemDate) { + result.pubDate = parseDate(itemDate, 'YYYY年MM月DD日'); + } + return result; + }); + }) + ); + + ctx.state.data = { + title: `中国研究生招生信息网 - 热点`, + link: host, + description: '中国研究生招生信息网 - 热点', + item: items, + }; +}; diff --git a/lib/v2/chsi/maintainer.js b/lib/v2/chsi/maintainer.js index 460924536..f1c5a83e9 100644 --- a/lib/v2/chsi/maintainer.js +++ b/lib/v2/chsi/maintainer.js @@ -1,3 +1,4 @@ module.exports = { + '/hotnews': ['yanbot-team'], '/kydt': ['SunBK201'], }; diff --git a/lib/v2/chsi/radar.js b/lib/v2/chsi/radar.js index 9d3eaf312..635b6998a 100644 --- a/lib/v2/chsi/radar.js +++ b/lib/v2/chsi/radar.js @@ -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', + }, ], }, }; diff --git a/lib/v2/chsi/router.js b/lib/v2/chsi/router.js index 1d9b11eb3..b80d289fa 100644 --- a/lib/v2/chsi/router.js +++ b/lib/v2/chsi/router.js @@ -1,3 +1,4 @@ module.exports = (router) => { + router.get('/hotnews', require('./hotnews')); router.get('/kydt', require('./kydt')); };