diff --git a/docs/study.md b/docs/study.md index db8106c84..d66716cb1 100644 --- a/docs/study.md +++ b/docs/study.md @@ -651,6 +651,12 @@ path="/ctfhub/upcoming/:limit?" +## 中国研究生招生信息网 + +### 考研动态 + + + ## 中国智库网 ### 观点与实践 diff --git a/lib/v2/chsi/kydt.js b/lib/v2/chsi/kydt.js new file mode 100644 index 000000000..66aa5c409 --- /dev/null +++ b/lib/v2/chsi/kydt.js @@ -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 response = await got(`${host}/kyzx/kydt`); + + const $ = cheerio.load(response.data); + 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('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://')) { + 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: `中国研究生招生信息网 - 考研动态`, + link: `${host}/kyzx/kydt/`, + description: '中国研究生招生信息网 - 考研动态', + item: items, + }; +}; diff --git a/lib/v2/chsi/maintainer.js b/lib/v2/chsi/maintainer.js new file mode 100644 index 000000000..460924536 --- /dev/null +++ b/lib/v2/chsi/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/kydt': ['SunBK201'], +}; diff --git a/lib/v2/chsi/radar.js b/lib/v2/chsi/radar.js new file mode 100644 index 000000000..9d3eaf312 --- /dev/null +++ b/lib/v2/chsi/radar.js @@ -0,0 +1,13 @@ +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: ['/kyzx/kydt'], + target: '/chsi/kydt', + }, + ], + }, +}; diff --git a/lib/v2/chsi/router.js b/lib/v2/chsi/router.js new file mode 100644 index 000000000..1d9b11eb3 --- /dev/null +++ b/lib/v2/chsi/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/kydt', require('./kydt')); +};