feat(route): add Stock Edge (#12950)
* feat(route): add Stock Edge * fix(parseTime): utils * Update docs/en/finance.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix(stockedge):minor changes ---------
This commit is contained in:
parent
d8de841c73
commit
3432b148d6
|
|
@ -125,6 +125,12 @@ Language
|
|||
|
||||
</RouteEn>
|
||||
|
||||
## Stock Edge
|
||||
|
||||
### Daily Updates News
|
||||
|
||||
<RouteEn author="Rjnishant530" example="/stockedge/daily-updates/news" path="/stockedge/daily-updates/news" radar="1"/>
|
||||
|
||||
## TokenInsight
|
||||
|
||||
::: tip Tips
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
const { getData, getList } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://web.stockedge.com/daily-updates?section=news';
|
||||
const apiPath = 'https://api.stockedge.com/Api/DailyDashboardApi/GetLatestNewsItems';
|
||||
const apiInfo = 'https://api.stockedge.com/Api/SecurityDashboardApi/GetSecurityOverview';
|
||||
|
||||
const data = await getData(apiPath);
|
||||
const list = getList(data);
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const info = await getData(`${apiInfo}/${item.securityID}`);
|
||||
item.description = info?.AboutCompanyText;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Stock Edge',
|
||||
link: baseUrl,
|
||||
item: items,
|
||||
description: 'Daily Updates on stockedge.com',
|
||||
logo: 'https://web.stockedge.com/assets/icon/favicon.png',
|
||||
icon: 'https://web.stockedge.com/assets/img/light/icon.png',
|
||||
language: 'en-us',
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/daily-updates/news': ['Rjnishant530'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'stockedge.com': {
|
||||
_name: 'Stock Edge',
|
||||
'.': [
|
||||
{
|
||||
title: 'Daily Updates News',
|
||||
docs: 'https://docs.rsshub.app/en/finance.html#stock-edge',
|
||||
source: ['/daily-updates/news'],
|
||||
target: '/stockedge/daily-updates/news',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/daily-updates/news', require('./daily-news'));
|
||||
};
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const baseUrl = 'https://web.stockedge.com/share/';
|
||||
const getData = (url) =>
|
||||
got
|
||||
.get(url, {
|
||||
headers: {
|
||||
Host: 'api.stockedge.com',
|
||||
Origin: 'https://web.stockedge.com',
|
||||
Referer: 'https://web.stockedge.com/',
|
||||
accept: 'application/json, text/plain, */*',
|
||||
},
|
||||
})
|
||||
.json();
|
||||
|
||||
const getList = (data) =>
|
||||
data.map((value) => {
|
||||
const { ID, Description: title, Date: createdOn, NewsitemSecurities, NewsitemSectors, NewsitemIndustries } = value;
|
||||
const securityID = NewsitemSecurities[0].SecurityID;
|
||||
return {
|
||||
id: ID,
|
||||
title: `${title} [${NewsitemSectors.map((v) => v.SectorName).join(', ')}]`,
|
||||
securityID,
|
||||
link: `${baseUrl}${NewsitemSecurities[0].SecuritySlug}/${securityID}`,
|
||||
pubDate: parseDate(createdOn),
|
||||
category: [...NewsitemIndustries.map((v) => v.IndustryName), ...NewsitemSectors.map((v) => v.SectorName)],
|
||||
};
|
||||
});
|
||||
|
||||
module.exports = { getData, getList };
|
||||
Loading…
Reference in New Issue