+wallstreetcn router (#1405)

+wallstreetcn router
This commit is contained in:
xu yang 2019-01-16 18:29:55 +08:00 committed by DIYgod
parent 49f2c42e1a
commit e3f4f2f6ca
3 changed files with 40 additions and 0 deletions

View File

@ -2014,6 +2014,10 @@ Solidot 提供的 feed:
<route name="全球快讯" author="xyqfer" example="/geekpark/breakingnews" path="/geekpark/breakingnews" />
### 华尔街见闻
<route name="华尔街见闻" author="conanjunn" example="/wallstreetcn/news/global" path="/wallstreetcn/news/global" />
## 预报预警
### 停水通知

View File

@ -964,4 +964,7 @@ router.get('/jingdong/zhongchou/:type/:status/:sort', require('./routes/jingdong
// 淘宝众筹
router.get('/taobao/zhongchou/:type?', require('./routes/taobao/zhongchou'));
// 华尔街见闻
router.get('/wallstreetcn/news/global', require('./routes/wallstreetcn/news'));
module.exports = router;

View File

@ -0,0 +1,33 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const response = await axios({
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;
};