mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
fix(route): 华尔街见闻 (#8729)
This commit is contained in:
@@ -1286,8 +1286,8 @@ router.get('/taobao/zhongchou/:type?', lazyloadRouteHandler('./routes/taobao/zho
|
||||
router.get('/allpoetry/:order?', lazyloadRouteHandler('./routes/allpoetry/order'));
|
||||
|
||||
// 华尔街见闻
|
||||
router.get('/wallstreetcn/news/global', lazyloadRouteHandler('./routes/wallstreetcn/news'));
|
||||
router.get('/wallstreetcn/live/:channel?', lazyloadRouteHandler('./routes/wallstreetcn/live'));
|
||||
// router.get('/wallstreetcn/news/global', lazyloadRouteHandler('./routes/wallstreetcn/news'));
|
||||
// router.get('/wallstreetcn/live/:channel?', lazyloadRouteHandler('./routes/wallstreetcn/live'));
|
||||
|
||||
// 多抓鱼搜索
|
||||
router.get('/duozhuayu/search/:wd', lazyloadRouteHandler('./routes/duozhuayu/search'));
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
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,
|
||||
};
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://api-prod.wallstreetcn.com/apiv1/content/fabricate-articles?limit=30&channel=global',
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const stateData = {
|
||||
title: '华尔街见闻',
|
||||
link: 'https://wallstreetcn.com/news/global',
|
||||
description: '华尔街见闻-中国领先的商业和金融信息提供商,首创商业和金融信息“实时”模式,重要信息秒级推送。7*24小时全年不间断为用户提供资讯、数据、行情、研究和社区等服务。',
|
||||
item: [],
|
||||
};
|
||||
|
||||
if (data.data && Array.isArray(data.data.items)) {
|
||||
data.data.items.forEach((item) => {
|
||||
if (item.resource_type !== 'article') {
|
||||
return;
|
||||
}
|
||||
stateData.item.push({
|
||||
title: item.resource.title,
|
||||
description: item.resource.content_short,
|
||||
pubDate: new Date(item.resource.display_time * 1000).toUTCString(),
|
||||
guid: item.resource.id,
|
||||
link: decodeURI(item.resource.uri),
|
||||
author: item.resource.author && item.resource.author.display_name,
|
||||
});
|
||||
});
|
||||
}
|
||||
ctx.state.data = stateData;
|
||||
};
|
||||
40
lib/v2/wallstreetcn/live.js
Normal file
40
lib/v2/wallstreetcn/live.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const titles = {
|
||||
global: '要闻',
|
||||
'a-stock': 'A股',
|
||||
'us-stock': '美股',
|
||||
'hk-stock': '港股',
|
||||
forex: '外汇',
|
||||
commodity: '商品',
|
||||
financing: '理财',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'global';
|
||||
|
||||
const rootUrl = 'https://wallstreetcn.com';
|
||||
const apiRootUrl = 'https://api-one.wallstcn.com';
|
||||
const currentUrl = `${rootUrl}/live/${category}`;
|
||||
const apiUrl = `${apiRootUrl}/apiv1/content/lives?channel=${category}-channel&limit=${ctx.query.limit ?? 50}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
const items = response.data.data.items.map((item) => ({
|
||||
link: item.uri,
|
||||
title: item.title || item.content_text,
|
||||
description: item.content,
|
||||
pubDate: parseDate(item.display_time * 1000),
|
||||
author: item.author.display_name,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${titles[category]} - 实时快讯 - 华尔街见闻`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
5
lib/v2/wallstreetcn/maintainer.js
Normal file
5
lib/v2/wallstreetcn/maintainer.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
'/live/:category?': ['nczitzk'],
|
||||
'/news/:category?': ['nczitzk'],
|
||||
'/:category?': ['nczitzk'],
|
||||
};
|
||||
61
lib/v2/wallstreetcn/news.js
Normal file
61
lib/v2/wallstreetcn/news.js
Normal file
@@ -0,0 +1,61 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const titles = {
|
||||
global: '最新',
|
||||
shares: '股市',
|
||||
bonds: '债市',
|
||||
commodities: '商品',
|
||||
forex: '外汇',
|
||||
enterprise: '公司',
|
||||
'asset-manage': '资管',
|
||||
tmt: '科技',
|
||||
estate: '地产',
|
||||
car: '汽车',
|
||||
medicine: '医药',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'global';
|
||||
|
||||
const rootUrl = 'https://wallstreetcn.com';
|
||||
const apiRootUrl = 'https://api-one.wallstcn.com';
|
||||
const currentUrl = `${rootUrl}/live/${category}`;
|
||||
const apiUrl = `${apiRootUrl}/apiv1/content/information-flow?channel=${category}-channel&accept=article&limit=25`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
let items = response.data.data.items.map((item) => ({
|
||||
link: item.resource.uri,
|
||||
title: item.resource?.title,
|
||||
author: item.resource.author?.display_name,
|
||||
pubDate: parseDate(item.resource.display_time * 1000),
|
||||
}));
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.rich-text, .live-detail-html').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${titles[category]} - 资讯 - 华尔街见闻`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
19
lib/v2/wallstreetcn/radar.js
Normal file
19
lib/v2/wallstreetcn/radar.js
Normal file
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'wallstreetcn.com': {
|
||||
_name: '华尔街见闻',
|
||||
'.': [
|
||||
{
|
||||
title: '资讯',
|
||||
docs: 'https://docs.rsshub.app/traditional-media.html#hua-er-jie-jian-wen-zi-xun',
|
||||
source: ['/news/:category', '/'],
|
||||
target: '/wallstreetcn/news/:category?',
|
||||
},
|
||||
{
|
||||
title: '实时快讯',
|
||||
docs: 'https://docs.rsshub.app/traditional-media.html#hua-er-jie-jian-wen-shi-shi-kuai-xun',
|
||||
source: ['/live/:category', '/'],
|
||||
target: '/wallstreetcn/live/:category?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
5
lib/v2/wallstreetcn/router.js
Normal file
5
lib/v2/wallstreetcn/router.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/live/:category?', require('./live'));
|
||||
router.get('/news/:category?', require('./news'));
|
||||
router.get('/:category?', require('./news'));
|
||||
};
|
||||
Reference in New Issue
Block a user