feat: add hkse stock announcement (#3014)

This commit is contained in:
hillerliao
2019-09-09 11:38:30 +08:00
committed by DIYgod
parent f3057f77f5
commit 663e6d3477
6 changed files with 59 additions and 3 deletions
+4
View File
@@ -681,6 +681,10 @@ type 为 all 时,category 参数不支持 cost 和 free
<Route author="LogicJake" example="/cninfo/stock_announcement/000410" path="/cninfo/stock_announcement/:code" :paramsDesc="['股票代码']"/>
### 公司公告-A 股港股
<Route author="LogicJake hillerliao" example="/cninfo/announcement/002024/gqjl" path="/cninfo/announcement/:code/:category?" :paramsDesc="['股票代码, 若不指定公司则填 all', '公告分类,对A股有效如 gqjl 表示 股权激励 分类']"/>
### 基金公告
<Route author="hillerliao" example="/cninfo/fund_announcement/159977/基金合同" path="/cninfo/fund_announcement/:code/:searchkey" :paramsDesc="['基金代码, 若不指定则填 all', '过滤词,若不指定则填all']"/>
+1
View File
@@ -1506,6 +1506,7 @@ router.get('/docschina/jsweekly', require('./routes/docschina/jsweekly'));
router.get('/im2maker/:channel?', require('./routes/im2maker/index'));
// 巨潮资讯
router.get('/cninfo/announcement/:code?/:category?', require('./routes/cninfo/announcement'));
router.get('/cninfo/stock_announcement/:code', require('./routes/cninfo/stock_announcement'));
router.get('/cninfo/fund_announcement/:code?/:searchkey?', require('./routes/cninfo/fund_announcement'));
+51
View File
@@ -0,0 +1,51 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
let code = ctx.params.code;
const category = ctx.params.category || '';
if (code === 'all') {
code = '';
}
const url = `http://www.cninfo.com.cn/new/commonUrl?url=disclosure/list/notice-fund`;
const apiUrl = `http://www.cninfo.com.cn/new/hisAnnouncement/query?pageNum=1&pageSize=50&tabName=fulltext&column=&stock=${code}&searchkey=&secid=&plate=&category=category_${category}_szsh&trade=`;
const response = await got.post(apiUrl, {
headers: {
Referer: url,
},
});
const announcements = response.data.announcements;
let announcementsList = [];
for (let i = 0; i < announcements.length; i++) {
announcementsList = announcementsList.concat(announcements[i]);
}
let name = '';
const out = announcementsList.map((item) => {
const date = item.announcementTime;
const link = `http://static.cninfo.com.cn/${item.adjunctUrl}`;
name = item.secName;
const title = name + ': ' + item.announcementTitle;
const single = {
title,
link,
pubDate: new Date(date).toUTCString(),
};
return single;
});
if (code === '') {
name = '最新';
}
ctx.state.data = {
title: `${name}${category}-公告-巨潮资讯`,
link: url,
item: out,
};
};
+1 -1
View File
@@ -32,7 +32,7 @@ module.exports = async (ctx) => {
item: data.map((item) => {
const description = item.text;
return {
title: item.title ? item.title : description,
title: item.title ? item.title : description.replace(/<[^>]+>/g, ''),
description: item.text,
pubDate: new Date(item.created_at).toUTCString(),
link: `https://xueqiu.com${item.target}`,
+1 -1
View File
@@ -56,7 +56,7 @@ module.exports = async (ctx) => {
link: `https://xueqiu.com/S/${id}`,
description: `${stock_name} 的${source}`,
item: data.map((item) => ({
title: item.title !== '' ? item.title : item.description.replace(/<[^>]+>/g, '').slice(0, 30),
title: item.title !== '' ? item.title : item.description.replace(/<[^>]+>/g, ''),
description: item.description,
pubDate: new Date(item.created_at).toUTCString(),
link: `https://xueqiu.com${item.target}`,
+1 -1
View File
@@ -41,7 +41,7 @@ module.exports = async (ctx) => {
item: data.map((item) => {
const description = item.description + (item.retweeted_status ? `<blockquote>${item.retweeted_status.user.screen_name}:&nbsp;${item.retweeted_status.description}</blockquote>` : '');
return {
title: item.title ? item.title : description,
title: item.title ? item.title : description.replace(/<[^>]+>/g, ''),
description: description,
pubDate: new Date(item.created_at).toUTCString(),
link: `https://xueqiu.com${item.target}`,