diff --git a/docs/study.md b/docs/study.md index ddafa83616..f63c6278e4 100644 --- a/docs/study.md +++ b/docs/study.md @@ -533,6 +533,12 @@ path="/ctfhub/upcoming/:limit?" +## 中国留学网 + +### 通知公告 + + + ## 中国人事考试网 ### 通知公告 diff --git a/lib/v2/cscse/maintainer.js b/lib/v2/cscse/maintainer.js new file mode 100644 index 0000000000..b6d4a7abae --- /dev/null +++ b/lib/v2/cscse/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/tzgg': ['nczitzk'], +}; diff --git a/lib/v2/cscse/radar.js b/lib/v2/cscse/radar.js new file mode 100644 index 0000000000..37042aa74f --- /dev/null +++ b/lib/v2/cscse/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'cscse.edu.cn': { + _name: '中国留学网', + '.': [ + { + title: '通知公告', + docs: 'https://docs.rsshub.app/study.html#zhong-guo-liu-xue-wang-tong-zhi-gong-gao', + source: ['/cscse/index/tzgg', '/'], + target: '/cscse/tzgg', + }, + ], + }, +}; diff --git a/lib/v2/cscse/router.js b/lib/v2/cscse/router.js new file mode 100644 index 0000000000..a4b145745d --- /dev/null +++ b/lib/v2/cscse/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/tzgg', require('./tzgg')); +}; diff --git a/lib/v2/cscse/tzgg.js b/lib/v2/cscse/tzgg.js new file mode 100644 index 0000000000..7422c6fee9 --- /dev/null +++ b/lib/v2/cscse/tzgg.js @@ -0,0 +1,54 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.cscse.edu.cn'; + const currentUrl = `${rootUrl}/cscse/index/tzgg/index.html`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = $('.news_list li a') + .toArray() + .map((item) => { + item = $(item); + + const link = item.attr('href'); + + return { + title: item.text(), + link: `${/^http/.test(link) ? '' : rootUrl}${item.attr('href')}`, + pubDate: parseDate(item.next().text()), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description = content('.zoom').html(); + item.author = content('meta[name="Author"]').attr('content'); + item.category = content('meta[name="Keywords"]').attr('content')?.split(','); + + return item; + }) + ) + ); + + ctx.state.data = { + title: '中国留学网 - 通知公告', + link: currentUrl, + item: items, + }; +};