mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add 华尔街见闻实时快讯 (#5720)
This commit is contained in:
@@ -283,6 +283,16 @@ Type 栏目:
|
||||
|
||||
<Route author="conanjunn" example="/wallstreetcn/news/global" path="/wallstreetcn/news/global" />
|
||||
|
||||
### 实时快讯
|
||||
|
||||
<Route author="nczitzk" example="/wallstreetcn/live" path="/wallstreetcn/live/:channel?" :paramsDesc="['快讯分类,默认`global`,见下表']">
|
||||
|
||||
| 要闻 | A 股 | 美股 | 港股 | 外汇 | 商品 | 理财 |
|
||||
| ------ | ------- | -------- | -------- | ----- | --------- | --------- |
|
||||
| global | a-stock | us-stock | hk-stock | forex | commodity | financing |
|
||||
|
||||
</Route>
|
||||
|
||||
## 极客公园
|
||||
|
||||
### 全球快讯
|
||||
|
||||
@@ -1209,6 +1209,7 @@ router.get('/allpoetry/:order?', require('./routes/allpoetry/order'));
|
||||
|
||||
// 华尔街见闻
|
||||
router.get('/wallstreetcn/news/global', require('./routes/wallstreetcn/news'));
|
||||
router.get('/wallstreetcn/live/:channel?', require('./routes/wallstreetcn/live'));
|
||||
|
||||
// 多抓鱼搜索
|
||||
router.get('/duozhuayu/search/:wd', require('./routes/duozhuayu/search'));
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
const config = {
|
||||
global: '要闻',
|
||||
'a-stock': 'A股',
|
||||
'us-stock': '美股',
|
||||
'hk-stock': '港股',
|
||||
forex: '外汇',
|
||||
commodity: '商品',
|
||||
financing: '理财',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.params.channel = ctx.params.channel || 'global';
|
||||
|
||||
const currentUrl = `https://wallstreetcn.com/live/${ctx.params.channel}`;
|
||||
const rootUrl = `https://api.wallstcn.com/apiv1/content/lives?channel=${ctx.params.channel}-channel`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
|
||||
const items = response.data.data.items.map((item) => {
|
||||
let title;
|
||||
const match = item.content_text.match(/【(.*)】/);
|
||||
if (match !== null) {
|
||||
title = match[1];
|
||||
} else {
|
||||
title = item.content_text;
|
||||
}
|
||||
return {
|
||||
title,
|
||||
link: `https://wallstreetcn.com/livenews/${item.id}`,
|
||||
pubDate: new Date(item.display_time * 1000).toUTCString(),
|
||||
description: item.content,
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${config[ctx.params.channel]} - 实时快讯 - 华尔街见闻`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user