From fcbb3f402c294bcaab25cf7ab5eac07f34db5513 Mon Sep 17 00:00:00 2001 From: la3rence Date: Thu, 21 Dec 2023 22:46:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20mof=20(bond=20management)?= =?UTF-8?q?=20=E4=B8=AD=E5=8D=8E=E4=BA=BA=E6=B0=91=E5=85=B1=E5=92=8C?= =?UTF-8?q?=E5=9B=BD=E8=B4=A2=E6=94=BF=E9=83=A8-=E4=B8=93=E9=A2=98-?= =?UTF-8?q?=E6=94=BF=E5=BA=9C=E5=80=BA=E5=88=B8=E7=AE=A1=E7=90=86=20(#1409?= =?UTF-8?q?4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): add mof (bond management) * fix(router): re-order router config and add radar for mof * feat(router): radar param in route doc * fix(radar): add index source for mof * feat(radar): more source path for mof * Update website/docs/routes/government.mdx --------- --- lib/v2/gov/maintainer.js | 1 + lib/v2/gov/mof/bond.js | 51 ++++++++++++++++++++++++++++++ lib/v2/gov/radar.js | 14 ++++++++ lib/v2/gov/router.js | 1 + website/docs/routes/government.mdx | 12 +++++++ 5 files changed, 79 insertions(+) create mode 100644 lib/v2/gov/mof/bond.js diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index e6aa2467e5782f..36234344356f73 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -35,6 +35,7 @@ module.exports = { '/moa/:suburl': ['Origami404'], '/moe/:type': ['Crawler995'], '/moe/s78/:column': ['TonyRL'], + '/mof/bond/:category?': ['la3rence'], '/mofcom/article/:suffix+': ['LogicJake'], '/moj/aac/news/:type?': ['TonyRL'], '/mot/:category?': ['nczitzk'], diff --git a/lib/v2/gov/mof/bond.js b/lib/v2/gov/mof/bond.js new file mode 100644 index 00000000000000..70051bdec5ec25 --- /dev/null +++ b/lib/v2/gov/mof/bond.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 domain = 'gks.mof.gov.cn'; +const theme = 'guozaiguanli'; + +module.exports = async (ctx) => { + const { category = 'gzfxgzdt' } = ctx.params; + const currentUrl = `https://${domain}/ztztz/${theme}/${category}/`; + const { data: response } = await got(currentUrl); + const $ = cheerio.load(response); + const title = $('title').text(); + const author = $('div.zzName').text(); + const siteName = $('meta[name="SiteName"]').prop('content'); + const description = $('meta[name="ColumnDescription"]').prop('content'); + const indexes = $('ul.liBox li') + .toArray() + .map((li) => { + const a = $(li).find('a'); + const pubDate = $(li).find('span').text(); + const href = a.prop('href'); + const link = href.startsWith('http') ? href : new URL(href, currentUrl).href; + return { + title: a.prop('title'), + link, + pubDate: timezone(parseDate(pubDate), +8), + }; + }); + + const items = await Promise.all( + indexes.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: detailResponse } = await got(item.link); + const content = cheerio.load(detailResponse); + item.description = content('div.my_doccontent').html(); + item.author = author; + return item; + }) + ) + ); + + ctx.state.data = { + item: items, + title, + link: currentUrl, + description: `${description} - ${siteName}`, + author, + }; +}; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 9d9287eb42daed..371ec4219b7489 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -1053,6 +1053,20 @@ module.exports = { }, ], }, + 'mof.gov.cn': { + _name: '中华人民共和国财政部', + gks: [ + { + title: '专题: 政府债券管理', + docs: 'https://docs.rsshub.app/routes/government#zhong-hua-ren-min-gong-he-guo-cai-zheng-bu', + source: ['/ztztz/guozaiguanli/:category', '/ztztz/guozaiguanli/:category/*', '/ztztz/guozaiguanli/'], + target: (params) => { + const category = params.category; + return `/gov/mof/bond/${category ? category : ''}`; + }, + }, + ], + }, 'mofcom.gov.cn': { _name: '中华人民共和国商务部', '.': [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 206b80f20eb274..cdf8cf42f24c3a 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -29,6 +29,7 @@ module.exports = function (router) { router.get('/moa/:suburl(.*)', require('./moa/moa')); router.get('/moe/:type', require('./moe/moe')); router.get('/moe/s78/:column', require('./moe/s78')); + router.get('/mof/bond/:category?', require('./mof/bond')); router.get('/mofcom/article/:suffix+', require('./mofcom/article')); router.get('/moj/aac/news/:type?', require('./moj/aac/news')); router.get('/ndrc/fggz/:category*', require('./ndrc/fggz')); diff --git a/website/docs/routes/government.mdx b/website/docs/routes/government.mdx index f83942e9b20127..5b63dd958eb0af 100644 --- a/website/docs/routes/government.mdx +++ b/website/docs/routes/government.mdx @@ -1654,6 +1654,18 @@ +## 中华人民共和国财政部 {#zhong-hua-ren-min-gong-he-guo-cai-zheng-bu} + +### 专题 {#zhong-hua-ren-min-gong-he-guo-cai-zheng-bu-zhuan-ti} + + + #### 政府债券管理 + + | 国债管理工作动态 | 记账式国债 (含特别国债) 发行 | 储蓄国债发行 | 地方政府债券管理 | + | ---------------- | ---------------------------- | ------------ | --------------------- | + | gzfxgzdt | gzfxzjs | gzfxdzs | difangzhengfuzhaiquan | + + ## 中华人民共和国国家发展和改革委员会 {#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui} ### 新闻动态 {#zhong-hua-ren-min-gong-he-guo-guo-jia-fa-zhan-he-gai-ge-wei-yuan-hui-xin-wen-dong-tai}