mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
添加雪球股票的公告,研报,新闻 (#1671)
This commit is contained in:
@@ -608,6 +608,12 @@ RSSHub 提供下列 API 接口:
|
||||
|
||||
<route name="基金净值更新" author="HenryQW" example="/xueqiu/fund/040008" path="/xueqiu/fund/:id" :paramsDesc="['基金代码, 可在基金主页 URL 中找到. 此路由的数据为场外基金 (`F`开头)']"/>
|
||||
|
||||
<route name="股票信息" author="YuYang" example="/xueqiu/stock_info/SZ000002" path="/xueqiu/stock_info/:id/:type?" :paramsDesc="['股票代码(需要带上交易所)', '动态的类型, 不填则为股票公告']">
|
||||
|
||||
| 公告 | 新闻 | 研报 |
|
||||
| ------------ | ---- | -------- |
|
||||
| announcement | news | research |
|
||||
|
||||
### 龙腾网
|
||||
|
||||
<route name="转译网贴" author="sgqy" example="/ltaaa" path="/ltaaa/:type?" :paramsDesc="['热门类型.']">
|
||||
|
||||
@@ -463,6 +463,7 @@ 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'));
|
||||
router.get('/xueqiu/stock_info/:id/:type?', require('./routes/xueqiu/stock_info'));
|
||||
|
||||
// Greasy Fork
|
||||
router.get('/greasyfork/:language/:domain?', require('./routes/greasyfork/scripts'));
|
||||
|
||||
53
lib/routes/xueqiu/stock_info.js
Normal file
53
lib/routes/xueqiu/stock_info.js
Normal file
@@ -0,0 +1,53 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const type = ctx.params.type || 'announcement';
|
||||
const count = 10;
|
||||
const page = 1;
|
||||
const typename = {
|
||||
announcement: '公告',
|
||||
news: '自选股新闻',
|
||||
research: '研报',
|
||||
};
|
||||
const source = typename[type];
|
||||
|
||||
const res1 = await axios({
|
||||
method: 'get',
|
||||
url: `https://xueqiu.com/S/${id}`,
|
||||
});
|
||||
const token = res1.headers['set-cookie'].find((s) => s.startsWith('xq_a_token=')).split(';')[0];
|
||||
|
||||
const $ = cheerio.load(res1.data); // 使用 cheerio 加载返回的 HTML
|
||||
const html_title = $('title').text();
|
||||
const stock_name = html_title.split(' ')[0];
|
||||
|
||||
const res2 = await axios({
|
||||
method: 'get',
|
||||
url: 'https://xueqiu.com/statuses/stock_timeline.json',
|
||||
params: {
|
||||
symbol_id: id,
|
||||
source: source,
|
||||
count: count,
|
||||
page: page,
|
||||
},
|
||||
headers: {
|
||||
Cookie: token,
|
||||
Referer: `https://xueqiu.com/u/${id}`,
|
||||
},
|
||||
});
|
||||
|
||||
const data = res2.data.list;
|
||||
ctx.state.data = {
|
||||
title: `${stock_name} 的${source}`,
|
||||
link: `https://xueqiu.com/S/${id}`,
|
||||
description: `${stock_name} 的${source}`,
|
||||
item: data.map((item) => ({
|
||||
title: item.title !== '' ? item.title : item.description.split('<a')[0],
|
||||
description: item.description,
|
||||
pubDate: new Date(item.created_at).toUTCString(),
|
||||
link: `https://xueqiu.com${item.target}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user