From b387495beca851ee409d6bee5f4f79f3e903d4dd Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Sat, 20 Jan 2024 02:35:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=B8=AD=E5=9B=BD?= =?UTF-8?q?=E6=9C=9F=E8=B4=A7=E5=B8=82=E5=9C=BA=E7=9B=91=E6=8E=A7=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=20(#14287)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): add 中国期货市场监控中心 * Update lib/v2/cfmmc/radar.js --------- --- lib/v2/cfmmc/index.js | 72 +++++++++++++++++++++++++++++++++ lib/v2/cfmmc/maintainer.js | 3 ++ lib/v2/cfmmc/radar.js | 17 ++++++++ lib/v2/cfmmc/router.js | 3 ++ website/docs/routes/finance.mdx | 53 ++++++++++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 lib/v2/cfmmc/index.js create mode 100644 lib/v2/cfmmc/maintainer.js create mode 100644 lib/v2/cfmmc/radar.js create mode 100644 lib/v2/cfmmc/router.js diff --git a/lib/v2/cfmmc/index.js b/lib/v2/cfmmc/index.js new file mode 100644 index 000000000..107dcfcf2 --- /dev/null +++ b/lib/v2/cfmmc/index.js @@ -0,0 +1,72 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { id = 'main/noticeannouncement/cfmmcnotice' } = ctx.params; + const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 10; + + const rootUrl = 'http://www.cfmmc.com'; + const apiUrl = new URL('servlet/json', rootUrl).href; + const currentUrl = new URL(id.endsWith('/') ? id : `${id}/`, rootUrl).href; + + const { data: currentResponse } = await got(currentUrl); + + const $ = cheerio.load(currentResponse); + + const catalogId = $('#catalogId').prop('value'); + + const { data: response } = await got.post(apiUrl, { + form: { + funcNo: 741000, + catalog_id: catalogId, + branchNo: '', + curtPageNo: 1, + numPerPage: limit, + key_word: '', + start_date: '', + end_date: '', + }, + headers: { + referer: currentUrl, + }, + }); + + let items = + response.results?.[0].data.slice(0, limit).map((item) => ({ + title: item.title, + link: new URL(item.url, rootUrl).href, + pubDate: timezone(parseDate(item.publish_date), +8), + })) ?? []; + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: detailResponse } = await got(item.link); + + const content = cheerio.load(detailResponse); + + item.title = content('div.article_title h2').text(); + item.description = content('div.cont_txt').html(); + + return item; + }) + ) + ); + + const author = '中国期货市场监控中心'; + const image = new URL($('a.logo img').prop('src'), rootUrl).href; + + ctx.state.data = { + item: items, + title: `${author} - ${$('h3.SubPage_t3').text()}`, + link: currentUrl, + description: $('meta[name="Description"]').prop('content'), + language: 'zh', + image, + subtitle: $('meta[name="Keywords"]').prop('content'), + author, + allowEmpty: true, + }; +}; diff --git a/lib/v2/cfmmc/maintainer.js b/lib/v2/cfmmc/maintainer.js new file mode 100644 index 000000000..77e7f46e2 --- /dev/null +++ b/lib/v2/cfmmc/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:id?': ['nczitzk'], +}; diff --git a/lib/v2/cfmmc/radar.js b/lib/v2/cfmmc/radar.js new file mode 100644 index 000000000..198cff18a --- /dev/null +++ b/lib/v2/cfmmc/radar.js @@ -0,0 +1,17 @@ +module.exports = { + 'cfmmc.com': { + _name: '中国期货市场监控中心', + '.': [ + { + title: '栏目', + docs: 'https://docs.rsshub.app/routes/finance#zhong-guo-qi-huo-shi-chang-jian-kong-zhong-xin-lan-mu', + source: ['/:id*'], + target: (params) => { + const id = params.id.replace(/\/index\.shtml/, ''); + + return `/cfmmc${id ? `/${id}` : ''}`; + }, + }, + ], + }, +}; diff --git a/lib/v2/cfmmc/router.js b/lib/v2/cfmmc/router.js new file mode 100644 index 000000000..294b473e1 --- /dev/null +++ b/lib/v2/cfmmc/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:id*', require('./')); +}; diff --git a/website/docs/routes/finance.mdx b/website/docs/routes/finance.mdx index 3cbc9a777..1ca499b70 100644 --- a/website/docs/routes/finance.mdx +++ b/website/docs/routes/finance.mdx @@ -792,6 +792,59 @@ TokenInsight also provides official RSS, you can take a look at [https://api.tok | company | 公司 | +## 中国期货市场监控中心 {#zhong-guo-qi-huo-shi-chang-jian-kong-zhong-xin} + +### 栏目 {#zhong-guo-qi-huo-shi-chang-jian-kong-zhong-xin-lan-mu} + + + +#### 党的建设 + +| 栏目 | id | +| -------- | -------------------------------------- | +| 党建动态 | main/partybuilding/partybuildingtrends | +| 基层风采 | main/partybuilding/basestyle | +| 学习园地 | main/partybuilding/learninggarden | + +#### 通知公告 + +| 栏目 | id | +| ---------------- | ----------------------------------- | +| 中国期货监控公告 | main/noticeannouncement/cfmmcnotice | +| 证监会公告 | main/noticeannouncement/csrcnotice | +| 上期所公告 | main/noticeannouncement/shfenotice | +| 郑商所公告 | main/noticeannouncement/czcenotice | +| 大商所公告 | main/noticeannouncement/dcenotice | +| 中金所公告 | main/noticeannouncement/cffexnotice | +| 广期所公告 | main/noticeannouncement/gfexnotice | + +#### 焦点新闻 + +| 栏目 | id | +| -------- | -------------------------------- | +| 财经要闻 | main/focusnews/financialnews | +| 专题聚焦 | main/focusnews/thematicfocus | +| 金融动态 | main/focusnews/financialdynamics | + +#### 保障基金 + +| 栏目 | id | +| -------- | ------------------------------------- | +| 基金概况 | main/securityfund/fundoverview | +| 政策法规 | main/securityfund/policiesregulations | +| 公告信息 | main/securityfund/noticeinformation | + +#### 政策法规 + +| 栏目 | id | +| -------------------- | --------------------------------------------- | +| 国家法律法规 | main/policiesregulations/lawsregulations | +| 部门规章及规范性文件 | main/policiesregulations/regulationsnormative | +| 行业法规政策 | main/policiesregulations/industrypolicies | +| 中国期货监控相关规则 | main/policiesregulations/cfmmcrules | + + + ## 中国人民银行 {#zhong-guo-ren-min-yin-hang} ### 沟通交流 {#zhong-guo-ren-min-yin-hang-gou-tong-jiao-liu}