monitor xueqiu user's stock (#839)
monitor xueqiu user's stock in rss format
This commit is contained in:
parent
8f7da3eb2e
commit
8b9060bec0
|
|
@ -494,6 +494,8 @@ RSSHub 提供下列 API 接口:
|
|||
|
||||
<route name="用户收藏动态" author="imlonghao" example="/xueqiu/favorite/8152922548" path="/xueqiu/favorite/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
||||
|
||||
<route name="用户自选动态" author="hillerliao" example="/xueqiu/user_stock/1247347556" path="/xueqiu/user_stock/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
||||
|
||||
<route name="基金净值更新" author="HenryQW" example="/xueqiu/fund/040008" path="/xueqiu/fund/:id" :paramsDesc="['基金代码, 可在基金主页 URL 中找到. 此路由的数据为场外基金 (`F`开头)']"/>
|
||||
|
||||
## 编程
|
||||
|
|
|
|||
|
|
@ -400,6 +400,7 @@ router.get('/wikipedia/mainland', require('./routes/wikipedia/mainland'));
|
|||
// 雪球
|
||||
router.get('/xueqiu/user/:id/:type?', require('./routes/xueqiu/user'));
|
||||
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'));
|
||||
|
||||
// Greasy Fork
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
const axios = require('../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
||||
const res1 = await axios({
|
||||
method: 'get',
|
||||
url: 'https://xueqiu.com/',
|
||||
});
|
||||
const token = res1.headers['set-cookie'].find((s) => s.startsWith('xq_a_token=')).split(';')[0];
|
||||
|
||||
const res2 = await axios({
|
||||
method: 'get',
|
||||
url: 'https://xueqiu.com/v4/stock/portfolio/stocks.json?size=10000&type=1&pid=-1&category=2',
|
||||
params: {
|
||||
uid: id,
|
||||
},
|
||||
headers: {
|
||||
Cookie: token,
|
||||
Referer: `https://xueqiu.com/u/${id}`,
|
||||
},
|
||||
});
|
||||
const data = res2.data.stocks;
|
||||
|
||||
const res3 = await axios({
|
||||
method: 'get',
|
||||
url: 'https://xueqiu.com/statuses/original/show.json',
|
||||
params: {
|
||||
user_id: id,
|
||||
},
|
||||
headers: {
|
||||
Cookie: token,
|
||||
Referer: `https://xueqiu.com/u/${id}`,
|
||||
},
|
||||
});
|
||||
const screen_name = res3.data.user.screen_name;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${screen_name} 的雪球自选动态`,
|
||||
link: `https://xueqiu.com/u/${id}`,
|
||||
description: `@${screen_name} 的雪球自选动态`,
|
||||
item: data.map((item) => ({
|
||||
title: `@${screen_name} 关注了股票 ${item.stockName}`,
|
||||
description: `@${screen_name} 在${new Date(item.createAt).toLocaleString()} 关注了 ${item.stockName}(${item.exchange}:${item.code})。`,
|
||||
pubDate: new Date(item.createAt).toUTCString(),
|
||||
link: `https://xueqiu.com/s/${item.code}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue