mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 13:08:14 +08:00
feat: add 中证网中证快讯 & 行业资讯 (#4920)
This commit is contained in:
@@ -105,3 +105,15 @@ pageClass: routes
|
|||||||
### 货币政策司公开市场交易公告
|
### 货币政策司公开市场交易公告
|
||||||
|
|
||||||
<Route author="nczitzk" example="/pbc/tradeAnnouncement" path="/pbc/tradeAnnouncement"/>
|
<Route author="nczitzk" example="/pbc/tradeAnnouncement" path="/pbc/tradeAnnouncement"/>
|
||||||
|
|
||||||
|
## 中证网
|
||||||
|
|
||||||
|
### 资讯
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/cs/news/zzkx" path="/cs/news/:caty" :paramsDesc="['资讯类型']">
|
||||||
|
|
||||||
|
| 中证快讯 | 行业资讯 |
|
||||||
|
| -------- | -------- |
|
||||||
|
| zzkx | hyzx |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|||||||
@@ -2814,6 +2814,9 @@ router.get('/gov/caict/bps', require('./routes/gov/caict/bps'));
|
|||||||
router.get('/gov/caict/qwsj', require('./routes/gov/caict/qwsj'));
|
router.get('/gov/caict/qwsj', require('./routes/gov/caict/qwsj'));
|
||||||
router.get('/gov/caict/caictgd', require('./routes/gov/caict/caictgd'));
|
router.get('/gov/caict/caictgd', require('./routes/gov/caict/caictgd'));
|
||||||
|
|
||||||
|
// 中证网
|
||||||
|
router.get('/cs/news/:caty', require('./routes/cs/news'));
|
||||||
|
|
||||||
// 财联社
|
// 财联社
|
||||||
router.get('/cls/telegraph', require('./routes/cls/telegraph'));
|
router.get('/cls/telegraph', require('./routes/cls/telegraph'));
|
||||||
router.get('/cls/depth', require('./routes/cls/depth'));
|
router.get('/cls/depth', require('./routes/cls/depth'));
|
||||||
|
|||||||
63
lib/routes/cs/news.js
Normal file
63
lib/routes/cs/news.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
const url = require('url');
|
||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const iconv = require('iconv-lite');
|
||||||
|
|
||||||
|
const rootUrl = 'http://www.cs.com.cn/';
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
zzkx: {
|
||||||
|
link: '/sylm/jsbd/',
|
||||||
|
title: '中证快讯',
|
||||||
|
},
|
||||||
|
hyzx: {
|
||||||
|
link: '/cj/hyzx/',
|
||||||
|
title: '行业资讯',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const cfg = config[ctx.params.caty];
|
||||||
|
if (!cfg) {
|
||||||
|
throw Error('Bad category. See <a href="https://docs.rsshub.app/finance.html#zhong-zheng-wang-zi-xun">docs</a>');
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentUrl = url.resolve(rootUrl, cfg.link);
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: currentUrl,
|
||||||
|
responseType: 'buffer',
|
||||||
|
});
|
||||||
|
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
|
||||||
|
const list = $('ul.list-lm li')
|
||||||
|
.slice(0, 20)
|
||||||
|
.map((_, item) => {
|
||||||
|
item = $(item);
|
||||||
|
const a = item.find('a');
|
||||||
|
return {
|
||||||
|
title: a.text(),
|
||||||
|
link: url.resolve(currentUrl, a.attr('href')),
|
||||||
|
pubDate: new Date(item.find('span').text()).toUTCString(),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(
|
||||||
|
async (item) =>
|
||||||
|
await ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const res = await got({ method: 'get', url: item.link, responseType: 'buffer' });
|
||||||
|
const content = cheerio.load(iconv.decode(res.data, 'gbk'));
|
||||||
|
|
||||||
|
item.description = content('div.article-t').html();
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '中证网 - ' + cfg.title,
|
||||||
|
link: rootUrl,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user