From 43db2dbf9699ece10978af76bd2afc48dd633557 Mon Sep 17 00:00:00 2001 From: Chenyang Shi Date: Tue, 16 Jul 2019 11:25:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E5=B7=A8=E6=BD=AE=E8=B5=84?= =?UTF-8?q?=E8=AE=AF=E7=BD=91-=E4=B8=AA=E8=82=A1=E5=85=AC=E5=91=8A=20(#261?= =?UTF-8?q?5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add 巨潮资讯网-个股公告 * delete Promise.all Co-authored-by: DIYgod --- docs/other.md | 6 ++++ lib/router.js | 3 ++ lib/routes/cninfo/stock_announcement.js | 42 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 lib/routes/cninfo/stock_announcement.js diff --git a/docs/other.md b/docs/other.md index 0033212e61..67711e8b49 100644 --- a/docs/other.md +++ b/docs/other.md @@ -548,6 +548,12 @@ type 为 all 时,category 参数不支持 cost 和 free +## 巨潮资讯 + +### 公司公告 + + + ## 决胜网 ### 最新资讯 diff --git a/lib/router.js b/lib/router.js index debcd00b35..57ab3dffb2 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1495,6 +1495,9 @@ router.get('/aptonic/action', require('./routes/aptonic/action')); // 印记中文周刊 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')); diff --git a/lib/routes/cninfo/stock_announcement.js b/lib/routes/cninfo/stock_announcement.js new file mode 100644 index 0000000000..d8f362db9a --- /dev/null +++ b/lib/routes/cninfo/stock_announcement.js @@ -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, + }; +};