diff --git a/docs/finance.md b/docs/finance.md index 214875a822..f591ecc4d8 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -369,11 +369,19 @@ pageClass: routes ### 沟通交流 - + ### 货币政策司公开市场交易公告 - + + +### 政策研究 + + + +### 工作论文 + + ## 中证网 diff --git a/lib/router.js b/lib/router.js index 7777a68d0e..21f540ba0b 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2837,10 +2837,6 @@ router.get('/aljazeera/news', lazyloadRouteHandler('./routes/aljazeera/news')); // CFD indices dividend adjustment router.get('/cfd/gbp_div', lazyloadRouteHandler('./routes/cfd/gbp_div')); -// 中国人民银行 -router.get('/pbc/goutongjiaoliu', lazyloadRouteHandler('./routes/pbc/goutongjiaoliu')); -router.get('/pbc/tradeAnnouncement', lazyloadRouteHandler('./routes/pbc/tradeAnnouncement')); - // Monotype router.get('/monotype/article', lazyloadRouteHandler('./routes/monotype/article')); diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 2dbd37212e..8a8355f99d 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -13,4 +13,8 @@ module.exports = { '/miit/wjgs': ['Yoge-Code'], '/miit/zcjd': ['Yoge-Code'], '/mee/ywdt?': ['liuxsdev'], + '/pbc/goutongjiaoliu': ['nczitzk'], + '/pbc/tradeAnnouncement': ['nczitzk'], + '/pbc/zcyj': ['Fatpandac'], + '/pbc/gzlw': ['Fatpandac'], }; diff --git a/lib/routes/pbc/goutongjiaoliu.js b/lib/v2/gov/pbc/goutongjiaoliu.js similarity index 80% rename from lib/routes/pbc/goutongjiaoliu.js rename to lib/v2/gov/pbc/goutongjiaoliu.js index 9eba4ca4c1..914896965f 100644 --- a/lib/routes/pbc/goutongjiaoliu.js +++ b/lib/v2/gov/pbc/goutongjiaoliu.js @@ -1,8 +1,9 @@ -const url = require('url'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); module.exports = async (ctx) => { - const link = `http://www.pbc.gov.cn/goutongjiaoliu/113456/113469/index.html`; + const link = 'http://www.pbc.gov.cn/goutongjiaoliu/113456/113469/index.html'; const browser = await require('@/utils/puppeteer')(); const page = await browser.newPage(); @@ -19,8 +20,7 @@ module.exports = async (ctx) => { const a = item.find('a[title]'); return { title: a.text(), - link: url.resolve(`http://www.pbc.gov.cn`, a.attr('href')), - pubDate: new Date(item.next('span.hui12').text()).toUTCString(), + link: new URL(a.attr('href'), 'http://www.pbc.gov.cn'), }; }) .get(); @@ -37,6 +37,7 @@ module.exports = async (ctx) => { ); const content = cheerio.load(detailHtml); item.description = content('#zoom').html(); + item.pubDate = timezone(parseDate(content('.hui12').eq(5).text()), +8); return item; }) ) diff --git a/lib/v2/gov/pbc/gzlw.js b/lib/v2/gov/pbc/gzlw.js new file mode 100644 index 0000000000..95da3ddb5e --- /dev/null +++ b/lib/v2/gov/pbc/gzlw.js @@ -0,0 +1,27 @@ +const { processItems } = require('./utils'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const host = 'http://www.pbc.gov.cn'; + +module.exports = async (ctx) => { + const url = `${host}/redianzhuanti/118742/4122386/4122692/index.html`; + + const response = await got.post(url); + const $ = cheerio.load(response.data); + const list = $('li.clearfix') + .map((_index, item) => ({ + title: $(item).find('a').text(), + link: new URL($(item).find('a').attr('href'), host).href, + author: $(item).find('span.fr').text().replace(/…/g, ''), + })) + .get(); + + const items = await processItems(list, ctx); + + ctx.state.data = { + title: '中国人民银行 工作论文', + link: url, + item: items, + }; +}; diff --git a/lib/routes/pbc/tradeAnnouncement.js b/lib/v2/gov/pbc/tradeAnnouncement.js similarity index 80% rename from lib/routes/pbc/tradeAnnouncement.js rename to lib/v2/gov/pbc/tradeAnnouncement.js index 5986f914b0..39762c7c12 100644 --- a/lib/routes/pbc/tradeAnnouncement.js +++ b/lib/v2/gov/pbc/tradeAnnouncement.js @@ -1,8 +1,9 @@ -const url = require('url'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); module.exports = async (ctx) => { - const link = `http://www.pbc.gov.cn/zhengcehuobisi/125207/125213/125431/125475/index.html`; + const link = 'http://www.pbc.gov.cn/zhengcehuobisi/125207/125213/125431/125475/index.html'; const browser = await require('@/utils/puppeteer')(); const page = await browser.newPage(); @@ -19,8 +20,7 @@ module.exports = async (ctx) => { const a = item.find('a[title]'); return { title: a.text(), - link: url.resolve(`http://www.pbc.gov.cn`, a.attr('href')), - pubDate: new Date(item.next('span.hui12').text()).toUTCString(), + link: new URL(a.attr('href'), 'http://www.pbc.gov.cn'), }; }) .get(); @@ -37,6 +37,7 @@ module.exports = async (ctx) => { ); const content = cheerio.load(detailHtml); item.description = content('#zoom').html(); + item.pubDate = timezone(parseDate(content('#shijian').text()), +8); return item; }) ) diff --git a/lib/v2/gov/pbc/utils.js b/lib/v2/gov/pbc/utils.js new file mode 100644 index 0000000000..8478f39121 --- /dev/null +++ b/lib/v2/gov/pbc/utils.js @@ -0,0 +1,20 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const processItems = async (list, ctx) => + await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got.post(item.link); + const content = cheerio.load(detailResponse.data); + + item.description = content('div.xxy_text').html(); + + return item; + }) + ) + ); + +module.exports = { + processItems, +}; diff --git a/lib/v2/gov/pbc/zcyj.js b/lib/v2/gov/pbc/zcyj.js new file mode 100644 index 0000000000..86ecd1b795 --- /dev/null +++ b/lib/v2/gov/pbc/zcyj.js @@ -0,0 +1,29 @@ +const { processItems } = require('./utils'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const host = 'http://www.pbc.gov.cn'; + +module.exports = async (ctx) => { + const url = `${host}/redianzhuanti/118742/4122386/4122510/index.html`; + + const response = await got.post(url); + const $ = cheerio.load(response.data); + const list = $('li.clearfix') + .map((_index, item) => ({ + title: $(item).find('a').text(), + link: new URL($(item).find('a').attr('href'), host).href, + pubDate: timezone(parseDate($(item).find('span.fr').text(), 'YYYY-MM-DD'), +8), + })) + .get(); + + const items = await processItems(list, ctx); + + ctx.state.data = { + title: '中国人民银行 政策研究', + link: url, + item: items, + }; +}; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 0d066e1f08..355d63b0d6 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -404,4 +404,33 @@ module.exports = { }, ], }, + 'pbc.gov.cn': { + _name: '中国人民银行', + '.': [ + { + title: '沟通交流', + docs: 'https://docs.rsshub.app/finance.html#zhong-guo-ren-min-yin-xing', + source: ['/goutongjiaoliu/113456/113469/index.html'], + target: '/gov/pbc/goutongjiaoliu', + }, + { + title: '货币政策司公开市场交易公告', + docs: 'https://docs.rsshub.app/finance.html#zhong-guo-ren-min-yin-xing', + source: ['/zhengcehuobisi/125207/125213/125431/125475/index.html'], + target: '/gov/pbc/zhengcehuobisi', + }, + { + title: '政策研究', + docs: 'https://docs.rsshub.app/finance.html#zhong-guo-ren-min-yin-xing', + source: ['/redianzhuanti/118742/4122386/4122510/index.html'], + target: '/gov/pbc/zcyj', + }, + { + title: '工作论文', + docs: 'https://docs.rsshub.app/finance.html#zhong-guo-ren-min-yin-xing', + source: ['/redianzhuanti/118742/4122386/4122692/index.html'], + target: '/gov/pbc/gzlw', + }, + ], + }, }; diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 3812a52ed9..bce3d95478 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -14,4 +14,8 @@ module.exports = function (router) { router.get('/miit/wjgs', require('./miit/wjgs')); router.get('/miit/zcjd', require('./miit/zcjd')); router.get('/mee/ywdt/:category?', require('./mee/ywdt')); + router.get('/pbc/goutongjiaoliu', require('./pbc/goutongjiaoliu')); + router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement')); + router.get('/pbc/gzlw', require('./pbc/gzlw')); + router.get('/pbc/zcyj', require('./pbc/zcyj')); };