feat: add sse comvetable (#2888)

This commit is contained in:
Cloud
2019-08-20 14:09:10 +08:00
committed by DIYgod
parent 4ad0862e01
commit 8fca98bdd4
3 changed files with 41 additions and 0 deletions

View File

@@ -855,6 +855,12 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="DIYgod" example="/shanbay/checkin/ddwej" path="/shanbay/checkin/:id" :paramsDesc="['用户 id']" /> <Route author="DIYgod" example="/shanbay/checkin/ddwej" path="/shanbay/checkin/:id" :paramsDesc="['用户 id']" />
## 上证债券信息网
### 可转换公司债券公告
<Route author="kt286" example="/sse/convert/beginDate=2018-08-18&endDate=2019-08-18&companyCode=603283&title=股份" path="/sse/convert/:query?" :paramsDesc="['筛选条件,见示例']"/>
## 少数派 sspai ## 少数派 sspai
### 最新上架付费专栏 ### 最新上架付费专栏

View File

@@ -1634,4 +1634,7 @@ router.get('/queshu/book/:bookid', require('./routes/queshu/book'));
// LaTeX 开源小屋 // LaTeX 开源小屋
router.get('/latexstudio/home', require('./routes/latexstudio/home')); router.get('/latexstudio/home', require('./routes/latexstudio/home'));
// 上证债券信息网 - 可转换公司债券公告
router.get('/sse/convert/:query?', require('./routes/sse/convert'));
module.exports = router; module.exports = router;

32
lib/routes/sse/convert.js Normal file
View File

@@ -0,0 +1,32 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const query = ctx.params.query || ''; // beginDate=2018-08-18&endDate=2019-08-18&companyCode=603283&title=股份
const pageUrl = 'http://bond.sse.com.cn/disclosure/announ/convertible/#';
const host = `http://www.sse.com.cn`;
const response = await got({
method: 'get',
url: `http://query.sse.com.cn/infodisplay/queryBulletinKzzTipsNew.do?isPagination=true&pageHelp.pageSize=2&flag=0&_=${new Date().getTime()}&${query.replace(/([\u4e00-\u9fa5])/g, (str) => encodeURIComponent(str))}`,
headers: {
Referer: pageUrl,
},
});
const items = response.data.result.map((item) => {
const single = {
title: item.title,
description: `${host}${item.URL}`,
pubDate: new Date(item.SSEDate).toUTCString(),
link: `${host}${item.URL}`,
author: item.security_Code,
};
return single;
});
ctx.state.data = {
title: '上证债券信息网 - 可转换公司债券公告',
link: pageUrl,
item: items,
};
};