From 92e609ef5a69e22bf0b860d1eb115bf86bbe5320 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 9 Feb 2024 22:44:50 +0800 Subject: [PATCH] feat(route): chinamoney (#14437) --- lib/v2/chinamoney/channels.js | 57 ++++++++++++++++++++++++++++++ lib/v2/chinamoney/maintainer.js | 3 ++ lib/v2/chinamoney/notice.js | 61 +++++++++++++++++++++++++++++++++ lib/v2/chinamoney/radar.js | 11 ++++++ lib/v2/chinamoney/router.js | 3 ++ website/docs/routes/finance.mdx | 38 ++++++++++++++++++++ 6 files changed, 173 insertions(+) create mode 100644 lib/v2/chinamoney/channels.js create mode 100644 lib/v2/chinamoney/maintainer.js create mode 100644 lib/v2/chinamoney/notice.js create mode 100644 lib/v2/chinamoney/radar.js create mode 100644 lib/v2/chinamoney/router.js diff --git a/lib/v2/chinamoney/channels.js b/lib/v2/chinamoney/channels.js new file mode 100644 index 000000000..77d2b9a18 --- /dev/null +++ b/lib/v2/chinamoney/channels.js @@ -0,0 +1,57 @@ +const channels = { + 2834: { + title: '最新 - 外汇市场公告 - 市场公告', + urlPath: '/chinese/scgg-whscgg/', + }, + 2835: { + title: '市场公告通知 - 外汇市场公告 - 市场公告', + urlPath: '/chinese/scgg-whscgg/', + }, + 2836: { + title: '中心会员公告 - 外汇市场公告 - 市场公告', + urlPath: '/chinese/scgg-whscgg/', + }, + 2837: { + title: '会员信息公告 - 外汇市场公告 - 市场公告', + urlPath: '/chinese/scgg-whscgg/', + }, + // + '2839,2840,2841': { + title: '最新 - 本币市场公告 - 市场公告', + urlPath: '/chinese/scggbbscgg/', + }, + 2839: { + title: '市场公告通知 - 本币市场公告 - 市场公告', + urlPath: '/chinese/scggbbscgg/', + }, + 2840: { + title: '中心成员公告 - 本币市场公告 - 市场公告', + urlPath: '/chinese/scggbbscgg/', + }, + 2841: { + title: '成员信息公告 - 本币市场公告 - 市场公告', + urlPath: '/chinese/scggbbscgg/', + }, + // + '2845,2846': { + title: '最新 - 央行业务公告 - 市场公告', + urlPath: '/chinese/scggyhywgg/', + }, + 2845: { + title: '公开市场操作 - 央行业务公告 - 市场公告', + urlPath: '/chinese/scggyhywgg/', + }, + 2846: { + title: '中央国库现金管理 - 央行业务公告 - 市场公告', + urlPath: '/chinese/scggyhywgg/', + }, + // + 3686: { + title: 'LPR市场公告 - 贷款市场报价利率 - 本币市场', + urlPath: '/chinese/bklpr/', + }, +}; + +module.exports = { + channels, +}; diff --git a/lib/v2/chinamoney/maintainer.js b/lib/v2/chinamoney/maintainer.js new file mode 100644 index 000000000..5e76af008 --- /dev/null +++ b/lib/v2/chinamoney/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:channelId?': ['TonyRL'], +}; diff --git a/lib/v2/chinamoney/notice.js b/lib/v2/chinamoney/notice.js new file mode 100644 index 000000000..21f99ca08 --- /dev/null +++ b/lib/v2/chinamoney/notice.js @@ -0,0 +1,61 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { channels } = require('./channels'); + +module.exports = async (ctx) => { + const { channelId = 2834 } = ctx.params; + const baseUrl = 'https://www.chinamoney.com.cn'; + + const { data: contents } = await got.post(`${baseUrl}/ags/ms/cm-s-notice-query/contents`, { + form: { + pageNo: 1, + pageSize: 15, + channelId, + }, + }); + + const list = contents.records.map((item) => ({ + title: item.title, + link: `${baseUrl}${item.draftPath}`, + pubDate: timezone(parseDate(item.releaseDate, 'YYYY-MM-DD'), +8), + contentId: item.contentId, + })); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: response } = await got(item.link); + const $ = cheerio.load(response); + + const article = $('.article-a-body'); + article.find('*').removeAttr('style'); + article.find('font').each((_, ele) => { + $(ele).replaceWith($(ele).html()); + }); + article.find('span').each((_, ele) => { + $(ele).replaceWith($(ele).html()); + }); + article.find('.article-a-attach-body a').each((i, ele) => { + ele = $(ele); + if (ele.attr('onclick')?.startsWith("location.href=encodeURI($('#fileDownUrl').val()+'fileDownLoad.do")) { + ele.attr('href', `${baseUrl}/dqs/cm-s-notice-query/fileDownLoad.do?mode=open&contentId=${item.contentId}&priority=${i}`); + ele.removeAttr('onclick'); + } + }); + + item.description = article.html(); + item.pubDate = timezone(parseDate($('.AC-l span').text().trim(), 'YYYY-MM-DD HH:mm'), +8); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${channels[channelId] ? channels[channelId].title + ' - ' : ''}中国货币网`, + link: `${baseUrl}${channels[channelId]?.urlPath ?? ''}`, + item: items, + }; +}; diff --git a/lib/v2/chinamoney/radar.js b/lib/v2/chinamoney/radar.js new file mode 100644 index 000000000..66fdf1811 --- /dev/null +++ b/lib/v2/chinamoney/radar.js @@ -0,0 +1,11 @@ +module.exports = { + 'chinamoney.com.cn': { + _name: '中国货币网', + '.': [ + { + title: '公告', + docs: 'https://docs.rsshub.app/routes/finance#zhong-guo-huo-bi-wang', + }, + ], + }, +}; diff --git a/lib/v2/chinamoney/router.js b/lib/v2/chinamoney/router.js new file mode 100644 index 000000000..ee182e0f0 --- /dev/null +++ b/lib/v2/chinamoney/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:channelId?', require('./notice')); +}; diff --git a/website/docs/routes/finance.mdx b/website/docs/routes/finance.mdx index 61e05e1b9..3185a561c 100644 --- a/website/docs/routes/finance.mdx +++ b/website/docs/routes/finance.mdx @@ -833,6 +833,44 @@ TokenInsight also provides official RSS, you can take a look at [https://api.tok | company | 公司 | +## 中国货币网 {#zhong-guo-huo-bi-wang} + +### 公告 {#zhong-guo-huo-bi-wang-gong-gao} + + +
+ 市场公告 + + 外汇市场公告 + + | 最新 | 市场公告通知 | 中心会员公告 | 会员信息公告 | + | ---- | ------------ | ------------ | ------------ | + | 2834 | 2835 | 2836 | 2837 | + + 本币市场公告 + + | 最新 | 市场公告通知 | 中心会员公告 | 会员信息公告 | + | -------------- | ------------ | ------------ | ------------ | + | 2839,2840,2841 | 2839 | 2840 | 2841 | + + 央行业务公告 + + | 最新 | 公开市场操作 | 中央国库现金管理 | + | --------- | ------------ | ---------------- | + | 2845,2846 | 2845 | 2846 | +
+ +
+ 本币市场 + + 贷款市场报价利率 + + | LPR 市场公告 | + | ------------ | + | 3686 | +
+
+ ## 中国期货市场监控中心 {#zhong-guo-qi-huo-shi-chang-jian-kong-zhong-xin} ### 栏目 {#zhong-guo-qi-huo-shi-chang-jian-kong-zhong-xin-lan-mu}