Skip to content

Commit

Permalink
feat(route): add mof (bond management) 中华人民共和国财政部-专题-政府债券管理 (#14094)
Browse files Browse the repository at this point in the history
* 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

---------
  • Loading branch information
la3rence authored Dec 21, 2023
1 parent 7a8c1bc commit fcbb3f4
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/v2/gov/maintainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
51 changes: 51 additions & 0 deletions lib/v2/gov/mof/bond.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
14 changes: 14 additions & 0 deletions lib/v2/gov/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '中华人民共和国商务部',
'.': [
Expand Down
1 change: 1 addition & 0 deletions lib/v2/gov/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
12 changes: 12 additions & 0 deletions website/docs/routes/government.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,18 @@

<Route author="HenryQW" example="/embassy/us/chicago" path="/embassy/:country/:city" paramsDesc={['国家短代码, 见支持国家列表', '城市, 对应国家列表下的`领事馆城市列表`']} />

## 中华人民共和国财政部 {#zhong-hua-ren-min-gong-he-guo-cai-zheng-bu}

### 专题 {#zhong-hua-ren-min-gong-he-guo-cai-zheng-bu-zhuan-ti}

<Route author="la3rence" example="/gov/mof/bond" path="/gov/mof/bond/:category?" paramsDesc={['专题,见下表,默认为国债管理工作动态']} radar="1">
#### 政府债券管理

| 国债管理工作动态 | 记账式国债 (含特别国债) 发行 | 储蓄国债发行 | 地方政府债券管理 |
| ---------------- | ---------------------------- | ------------ | --------------------- |
| gzfxgzdt | gzfxzjs | gzfxdzs | difangzhengfuzhaiquan |
</Route>

## 中华人民共和国国家发展和改革委员会 {#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}
Expand Down

0 comments on commit fcbb3f4

Please sign in to comment.