mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
feat: add 中国人民银行沟通交流新闻 & 货币政策司公开市场业务交易公告 (#4824)
This commit is contained in:
@@ -79,3 +79,13 @@ pageClass: routes
|
|||||||
| announcement | news | research |
|
| announcement | news | research |
|
||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 中国人民银行
|
||||||
|
|
||||||
|
### 沟通交流
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/pbc/goutongjiaoliu" path="/pbc/goutongjiaoliu"/>
|
||||||
|
|
||||||
|
### 货币政策司公开市场交易公告
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/pbc/tradeAnnouncement" path="/pbc/tradeAnnouncement"/>
|
||||||
|
|||||||
@@ -2726,4 +2726,8 @@ router.get('/grubstreet', require('./routes/grubstreet/index'));
|
|||||||
// Aljazeera 半岛网
|
// Aljazeera 半岛网
|
||||||
router.get('/aljazeera/news', require('./routes/aljazeera/news'));
|
router.get('/aljazeera/news', require('./routes/aljazeera/news'));
|
||||||
|
|
||||||
|
// 中国人民银行
|
||||||
|
router.get('/pbc/goutongjiaoliu', require('./routes/pbc/goutongjiaoliu'));
|
||||||
|
router.get('/pbc/tradeAnnouncement', require('./routes/pbc/tradeAnnouncement'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
53
lib/routes/pbc/goutongjiaoliu.js
Normal file
53
lib/routes/pbc/goutongjiaoliu.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
const url = require('url');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const link = `http://www.pbc.gov.cn/goutongjiaoliu/113456/113469/index.html`;
|
||||||
|
|
||||||
|
const browser = await require('@/utils/puppeteer')();
|
||||||
|
const page = await browser.newPage();
|
||||||
|
await page.goto(link);
|
||||||
|
const html = await page.evaluate(
|
||||||
|
() =>
|
||||||
|
// eslint-disable-next-line
|
||||||
|
document.querySelector('body').innerHTML
|
||||||
|
);
|
||||||
|
const $ = cheerio.load(html);
|
||||||
|
const list = $('font.newslist_style')
|
||||||
|
.map((_, item) => {
|
||||||
|
item = $(item);
|
||||||
|
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(),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(
|
||||||
|
async (item) =>
|
||||||
|
await ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailPage = await browser.newPage();
|
||||||
|
await detailPage.goto(item.link);
|
||||||
|
const detailHtml = await detailPage.evaluate(
|
||||||
|
() =>
|
||||||
|
// eslint-disable-next-line
|
||||||
|
document.querySelector('body').innerHTML
|
||||||
|
);
|
||||||
|
const content = cheerio.load(detailHtml);
|
||||||
|
item.description = content('#zoom').html();
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
browser.close();
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '中国人民银行 - 沟通交流',
|
||||||
|
link: link,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
53
lib/routes/pbc/tradeAnnouncement.js
Normal file
53
lib/routes/pbc/tradeAnnouncement.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
const url = require('url');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
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();
|
||||||
|
await page.goto(link);
|
||||||
|
const html = await page.evaluate(
|
||||||
|
() =>
|
||||||
|
// eslint-disable-next-line
|
||||||
|
document.querySelector('body').innerHTML
|
||||||
|
);
|
||||||
|
const $ = cheerio.load(html);
|
||||||
|
const list = $('font.newslist_style')
|
||||||
|
.map((_, item) => {
|
||||||
|
item = $(item);
|
||||||
|
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(),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(
|
||||||
|
async (item) =>
|
||||||
|
await ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailPage = await browser.newPage();
|
||||||
|
await detailPage.goto(item.link);
|
||||||
|
const detailHtml = await detailPage.evaluate(
|
||||||
|
() =>
|
||||||
|
// eslint-disable-next-line
|
||||||
|
document.querySelector('body').innerHTML
|
||||||
|
);
|
||||||
|
const content = cheerio.load(detailHtml);
|
||||||
|
item.description = content('#zoom').html();
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
browser.close();
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '中国人民银行 - 货币政策司公开市场交易公告',
|
||||||
|
link: link,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user