mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
feat: 添加雪球組合調倉信息 (#2568)
* Add xueqiu snb * Fix an error in doc * fix write style * Fix code style
This commit is contained in:
@@ -716,6 +716,10 @@ pageClass: routes
|
||||
|
||||
<Route author="HenryQW" example="/xueqiu/fund/040008" path="/xueqiu/fund/:id" :paramsDesc="['基金代码, 可在基金主页 URL 中找到. 此路由的数据为场外基金 (`F`开头)']"/>
|
||||
|
||||
### 组合最新调仓信息
|
||||
|
||||
<Route author="ZhishanZhang" example="/xueqiu/p/ZH1288184" path="/xueqiu/snb/:id" :paramsDesc="['组合代码, 可在组合主页 URL 中找到.']"/>
|
||||
|
||||
### 股票信息
|
||||
|
||||
<Route author="YuYang" example="/xueqiu/stock_info/SZ000002" path="/xueqiu/stock_info/:id/:type?" :paramsDesc="['股票代码(需要带上交易所)', '动态的类型, 不填则为股票公告']">
|
||||
|
||||
@@ -410,6 +410,7 @@ router.get('/xueqiu/favorite/:id', require('./routes/xueqiu/favorite'));
|
||||
router.get('/xueqiu/user_stock/:id', require('./routes/xueqiu/user_stock'));
|
||||
router.get('/xueqiu/fund/:id', require('./routes/xueqiu/fund'));
|
||||
router.get('/xueqiu/stock_info/:id/:type?', require('./routes/xueqiu/stock_info'));
|
||||
router.get('/xueqiu/snb/:id', require('./routes/xueqiu/snb'));
|
||||
|
||||
// Greasy Fork
|
||||
router.get('/greasyfork/:language/:domain?', require('./routes/greasyfork/scripts'));
|
||||
|
||||
40
lib/routes/xueqiu/snb.js
Normal file
40
lib/routes/xueqiu/snb.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const url = 'https://xueqiu.com/p/' + id;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: url,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const pattern = /SNB.cubeInfo = (.+?);/;
|
||||
const info = pattern.exec(data)[1];
|
||||
const obj = JSON.parse(info);
|
||||
const rebalancing_histories = obj.sell_rebalancing.rebalancing_histories;
|
||||
const snb_title = obj.name + ' 的调仓历史';
|
||||
const snb_description = obj.description;
|
||||
|
||||
const title = obj.name + ' 的上一笔调仓';
|
||||
let description = '';
|
||||
for (const some_detail of rebalancing_histories) {
|
||||
const prev_weight_adjusted = some_detail.prev_weight_adjusted ? some_detail.prev_weight_adjusted : 0;
|
||||
description += some_detail.stock_name + ' from ' + prev_weight_adjusted + ' to ' + some_detail.target_weight + ',\n';
|
||||
}
|
||||
|
||||
const single = {
|
||||
title,
|
||||
description,
|
||||
pubDate: new Date().toUTCString(),
|
||||
link: url,
|
||||
};
|
||||
|
||||
ctx.state.data = {
|
||||
title: snb_title,
|
||||
link: url,
|
||||
description: snb_description,
|
||||
item: [single],
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user