From aa6349d74e385fa08cfd207bd7ebad67eb7637c8 Mon Sep 17 00:00:00 2001 From: jialinghui Date: Sun, 23 Jan 2022 02:25:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):add=20=E4=B8=8A=E6=B5=B7=E5=B8=82?= =?UTF-8?q?=E6=95=99=E8=82=B2=E8=80=83=E8=AF=95=E9=99=A2=20-=20=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E9=80=9F=E9=80=92=20(#8714)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: jialinghui --- docs/other.md | 7 ++++++ lib/v2/shmeea/index.js | 44 +++++++++++++++++++++++++++++++++++++ lib/v2/shmeea/maintainer.js | 3 +++ lib/v2/shmeea/radar.js | 13 +++++++++++ lib/v2/shmeea/router.js | 3 +++ 5 files changed, 70 insertions(+) create mode 100644 lib/v2/shmeea/index.js create mode 100644 lib/v2/shmeea/maintainer.js create mode 100644 lib/v2/shmeea/radar.js create mode 100644 lib/v2/shmeea/router.js diff --git a/docs/other.md b/docs/other.md index 9a4756e3d3..f65440f13f 100644 --- a/docs/other.md +++ b/docs/other.md @@ -726,6 +726,13 @@ type 为 all 时,category 参数不支持 cost 和 free +## 上海市教育考试院 + +### 消息速递 + +官方网址: + + ## 上海证券交易所 ### 上市公司信息最新公告披露 diff --git a/lib/v2/shmeea/index.js b/lib/v2/shmeea/index.js new file mode 100644 index 0000000000..14067fd34d --- /dev/null +++ b/lib/v2/shmeea/index.js @@ -0,0 +1,44 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const baseURL = 'http://www.shmeea.edu.cn'; + const rootUrl = baseURL + '/page/08000/index.html'; + const response = await got({ + method: 'get', + url: rootUrl, + }); + + const data = response.data; + + const $ = cheerio.load(data); + + const list = $('#main .pageList li'); + + const items = await Promise.all( + list.map(async (i, item) => { + item = $(item); + const link = baseURL + item.find('a').attr('href'); + const description = await ctx.cache.tryGet(link, async () => { + const result = await got.get(link); + + const $ = cheerio.load(result.data); + + return $('#ivs_content').html(); + }); + return { + title: item.find('a').text(), + pubDate: new Date(item.find('.listTime').text()), + link, + description, + }; + }) + ); + + ctx.state.data = { + title: '上海市教育考试院', + description: '消息速递', + link: baseURL, + item: items, + }; +}; diff --git a/lib/v2/shmeea/maintainer.js b/lib/v2/shmeea/maintainer.js new file mode 100644 index 0000000000..4e3ee73d6b --- /dev/null +++ b/lib/v2/shmeea/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['jialinghui'], +}; diff --git a/lib/v2/shmeea/radar.js b/lib/v2/shmeea/radar.js new file mode 100644 index 0000000000..016d5b2d38 --- /dev/null +++ b/lib/v2/shmeea/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'shmeea.edu.cn': { + _name: '上海市教育考试院', + www: [ + { + title: '消息速递', + docs: 'https://docs.rsshub.app/other.html#shang-hai-shi-jiao-yu-kao-shi-yuan', + source: ['/'], + target: '/shmeea', + }, + ], + }, +}; diff --git a/lib/v2/shmeea/router.js b/lib/v2/shmeea/router.js new file mode 100644 index 0000000000..437937a54e --- /dev/null +++ b/lib/v2/shmeea/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('', require('./index')); +};