feat: add 巨潮资讯网-个股公告 (#2615)

* feat: add 巨潮资讯网-个股公告

* delete Promise.all


Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
Chenyang Shi
2019-07-16 11:25:18 +08:00
committed by DIYgod
parent 38676afb73
commit 43db2dbf96
3 changed files with 51 additions and 0 deletions

View File

@@ -548,6 +548,12 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="LogicJake" example="/whalegogo/home" path="/whalegogo/home"/> <Route author="LogicJake" example="/whalegogo/home" path="/whalegogo/home"/>
## 巨潮资讯
### 公司公告
<Route author="LogicJake" example="/cninfo/stock_announcement/000410" path="/cninfo/stock_announcement/:code" :paramsDesc="['股票代码']"/>
## 决胜网 ## 决胜网
### 最新资讯 ### 最新资讯

View File

@@ -1495,6 +1495,9 @@ router.get('/aptonic/action', require('./routes/aptonic/action'));
// 印记中文周刊 // 印记中文周刊
router.get('/docschina/jsweekly', require('./routes/docschina/jsweekly')); router.get('/docschina/jsweekly', require('./routes/docschina/jsweekly'));
// 巨潮资讯
router.get('/cninfo/stock_announcement/:code', require('./routes/cninfo/stock_announcement'));
// 中央纪委国家监委网站 // 中央纪委国家监委网站
router.get('/ccdi/scdc', require('./routes/ccdi/scdc')); router.get('/ccdi/scdc', require('./routes/ccdi/scdc'));

View File

@@ -0,0 +1,42 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const code = ctx.params.code;
const url = `http://www.cninfo.com.cn/new/disclosure/stock?plate=szse&stockCode=${code}`;
const apiUrl = `http://www.cninfo.com.cn/new/singleDisclosure/fulltext?stock=${code}&pageSize=20&pageNum=1&tabname=latest&plate=szse&limit=`;
const response = await got.post(apiUrl, {
headers: {
Referer: url,
},
});
const classifiedList = response.data.classifiedAnnouncements;
let announcementsList = [];
for (let i = 0; i < classifiedList.length; i++) {
announcementsList = announcementsList.concat(classifiedList[i]);
}
announcementsList = announcementsList.slice(0, 10);
let name = '';
const out = announcementsList.map((item) => {
const title = item.announcementTitle;
const date = item.announcementTime;
const link = `http://www.cninfo.com.cn/new/disclosure/detail?plate=szse&stockCode=${code}&announcementId=${item.announcementId}`;
name = item.secName;
const single = {
title,
link,
pubDate: new Date(date).toUTCString(),
};
return single;
});
ctx.state.data = {
title: `${name}公司公告-巨潮资讯`,
link: url,
item: out,
};
};