⏳ This skill is pending AI review.
Scores will appear once the review pipeline completes.
xueqiu-summary
雪球大V动态汇总与投资建议 — 自动抓取大V最新发帖 + 用户自选股行情,给出汇总摘要和投资参考建议
Choose how to use this skill
You do not need every option. Choose the path your AI client supports. The stable page stays the same; versioned files are immutable.
1. Native installer
This listing has no registered native installer command. Use the complete package or source fallback below, depending on what your client supports.
Do not guess an installer command or replace an existing version without reviewing the diff.
2. Complete package recommended
Download the ZIP when available. It includes SKILL.md plus the references, security notes and version metadata.
No complete ProSkills package is published for this listing yet.3. Prompt-only
Copy the prompt above when the agent can read the stable page or when you want to adopt the workflow without installing a skill.
Need only the instruction file?
Download SKILL.md only if your client requires a single file. The complete ZIP is safer for a full installation because it preserves the references and release context.
No path installs or executes anything by itself. Your agent still needs access to the project files. Before updating, compare the installed version and review the diff.
// RATINGS
// README
snow-summary
OpenClaw Skill — snow大V动态汇总与投资建议
自动抓取snow大V最新发帖 + 用户自选股实时行情,给出汇总摘要和投资参考建议。
功能
- 抓取关注的snow大V最新原创动态(Playwright + stealth 绕过 WAF)
- 获取snow自选股列表及实时行情(支持 A 股 / 港股 / 美股)
- 可选配置本地持仓,自动计算盈亏
- 输出五段式投资分析报告(大V观点摘要 → 行情概览 → 关联分析 → 投资建议 → 免责声明)
安装
1. 放到 OpenClaw skills 目录
# 克隆到 OpenClaw workspace skills 目录
git clone https://github.com/YOUR_USERNAME/xueqiu-summary.git \
~/.openclaw/workspace/skills/xueqiu-summary
2. 安装依赖
cd ~/.openclaw/workspace/skills/xueqiu-summary
bash install.sh
或手动安装:
npm install
npx playwright install chromium
3. 设置snow Token
export XQ_A_TOKEN="your_xq_a_token_here"
获取方式:浏览器打开 xueqiu.com → 登录 → F12 → Application → Cookies → 复制 xq_a_token 值。
4. 配置关注列表
cp watchlist.example.json watchlist.json
# 编辑 watchlist.json,添加你关注的大V
可选 — 配置持仓(用于计算盈亏):
cp portfolio.example.json portfolio.json
# 编辑 portfolio.json,填入你的持仓信息
如果不配置 portfolio.json,会自动从snow账号获取自选股列表。
使用
在 OpenClaw 对话中直接触发即可,agent 会自动识别该 skill 并执行数据抓取和分析。
也可以单独运行脚本:
# 获取大V动态
node fetch_timeline.js timeline "1247347556,5819606767" 5
# 获取自选股列表
node fetch_timeline.js watchlist
# 获取自选股 + 实时行情
node fetch_timeline.js watchlist_quotes
文件结构
xueqiu-summary/
├── SKILL.md # OpenClaw skill 定义(agent 读取此文件)
├── fetch_timeline.js # 数据抓取脚本(Playwright + stealth)
├── install.sh # 一键安装依赖
├── package.json # npm 依赖声明
├── watchlist.example.json # 大V关注列表示例
├── portfolio.example.json # 持仓配置示例
├── references/
│ └── api-reference.md # 雪球 API 参考文档
├── LICENSE
└── README.md
技术说明
| 数据 | 接口 | 方式 | 原因 |
|---|---|---|---|
| 大V动态 | xueqiu.com | Playwright + stealth | 主域名有阿里云 WAF |
| 自选股列表 | stock.xueqiu.com | Playwright (browser fetch) | 需浏览器上下文携带 cookie |
| 单只股票行情 | stock.xueqiu.com | curl | 子域名无 WAF |
免责声明
本项目仅供学习和个人使用。雪球 API 为非官方接口,请遵守雪球的使用条款。投资有风险,AI 生成的分析内容不构成任何投资建议。
License
MIT
// HOW IT'S BUILT
// FILES
9 files shipped with this skill. Inline text is the catalog copy. The upstream link is the source repository.
SKILL.md8.1 KBdd03beaebafaupstream ↗
--- name: xueqiu-summary description: 雪球大V动态汇总与投资建议 — 自动抓取大V最新发帖 + 用户自选股行情,给出汇总摘要和投资参考建议 user-invocable: true metadata: requires: node (with playwright-extra, puppeteer-extra-plugin-stealth), curl, jq primaryEnv: XQ_A_TOKEN --- # 雪球大V动态汇总与投资建议 你是一个专业的投资分析助手。你的任务是: 1. 抓取用户关注的雪球大V的最新动态 2. 获取用户的雪球自选股列表及实时行情 3. 结合以上信息给出汇总分析和投资参考建议 所有输出使用**中文**。 --- ## 认证与环境 ### 必需环境变量 ```bash export XQ_A_TOKEN="xq_a_token的值" ``` **执行前必须检查 `$XQ_A_TOKEN` 是否已设置。** 未设置时提示: > 请先设置雪球 Token:`export XQ_A_TOKEN="your_token"` > 获取方式:浏览器打开 xueqiu.com → 登录 → F12 → Application → Cookies → 复制 `xq_a_token` 值。 ### 技术架构 | 数据 | 接口域名 | 方式 | 原因 | |------|---------|------|------| | 大V动态 | xueqiu.com | Playwright + stealth | 主域名有阿里云 WAF,curl 无法通过 | | 自选股列表 | stock.xueqiu.com | Playwright (browser fetch) | 需浏览器上下文携带完整认证 cookie | | 单只股票行情 | stock.xueqiu.com | curl | 子域名无 WAF,仅需 xq_a_token | ### 依赖安装 skill 目录下有 `install.sh`,首次使用运行一次即可: ```bash bash {baseDir}/install.sh ``` 手动安装: ```bash cd {baseDir} && npm install playwright-extra puppeteer-extra-plugin-stealth && npx playwright install chromium ``` --- ## 配置文件 ### `{baseDir}/watchlist.json` — 大V关注列表 ```json [ { "user_id": "1247347556", "name": "段永平", "note": "价值投资" }, { "user_id": "5819606767", "name": "释老毛", "note": "港股深度" } ] ``` - `user_id`: 从雪球个人主页 URL `xueqiu.com/u/{user_id}` 获取 - `note`: 标签,用于报告中标注大V特长方向 ### `{baseDir}/portfolio.json` — 持仓配置(可选) ```json { "positions": [ { "symbol": "SH600519", "name": "贵州茅台", "shares": 100, "cost": 1680.00 }, { "symbol": "00700", "name": "腾讯控股", "shares": 500, "cost": 320.00 } ] } ``` 如果 `portfolio.json` 存在且有 positions 数据,报告中会计算盈亏。 **如果 `portfolio.json` 不存在或为空,则自动从雪球获取用户自选股列表作为关注标的。** 此时无持仓数量和成本价,不计算盈亏,仅展示行情。 --- ## 数据抓取脚本 `{baseDir}/fetch_timeline.js` 提供三个子命令: ### 1. 获取大V动态 ```bash node {baseDir}/fetch_timeline.js timeline "{user_id1},{user_id2},..." [count] ``` - 通过 Playwright + stealth 启动无头 Chromium - 先访问 xueqiu.com 首页通过 WAF(JS 执行 + cookie 设置) - 依次导航到每个用户的动态 API - 请求间隔 1.5 秒,每人默认 5 条原创帖(type=10) - 帖子正文已去除 HTML 标签,截取前 500 字 **输出格式(stdout):** ```json { "{user_id}": { "statuses": [ { "id": 376485375, "title": "", "text": "帖子纯文本...", "created_at": 1771541714000, "reply_count": 0, "retweet_count": 14, "like_count": 28 } ], "total": 10396 } } ``` 帖子链接:`https://xueqiu.com/{user_id}/{status_id}` ### 2. 获取自选股列表 ```bash node {baseDir}/fetch_timeline.js watchlist ``` 返回用户雪球账号的全部自选股代码和名称。 ### 3. 获取自选股列表 + 实时行情(推荐) ```bash node {baseDir}/fetch_timeline.js watchlist_quotes ``` 一次性返回自选股列表及每只股票的实时行情(现价、涨跌幅、PE、市值等)。 **输出格式(stdout):** ```json { "stocks": [ { "symbol": "00700", "name": "腾讯控股", "current": 522.0, "percent": -2.06, "chg": -11.0, "high": 533.0, "low": 518.0, "last_close": 533.0, "pe_ttm": 20.64, "pb": 3.62, "dividend_yield": 0.87, "market_capital": 4753517897250, "currency": "HKD", "exchange": "HK" } ] } ``` ### 4. 补充:单只股票行情(curl 备用) 行情子域名无 WAF,可用 curl 直接调用: ```bash curl -s -b 'xq_a_token=TOKEN' -H 'User-Agent: Mozilla/5.0' -H 'Referer: https://xueqiu.com/' \ 'https://stock.xueqiu.com/v5/stock/quote.json?symbol={symbol}&extend=detail' \ | jq '.data.quote | {symbol, name, current, percent, chg, high, low, pe_ttm, pb, dividend_yield, last_close}' ``` --- ## 执行流程 按以下顺序执行,**步骤 2 和步骤 3 可以并行**: ### 步骤 1:检查环境 - 验证 `$XQ_A_TOKEN` 已设置 - 读取 `{baseDir}/watchlist.json`(大V列表) - 读取 `{baseDir}/portfolio.json`(如果存在) ### 步骤 2:抓取大V动态 ```bash node {baseDir}/fetch_timeline.js timeline "{所有user_id逗号分隔}" 5 ``` 从 watchlist.json 提取所有 user_id,逗号拼接,一次调用。 ### 步骤 3:获取自选股行情 **方式 A**:portfolio.json 存在且有 positions — 用 curl 逐个查询持仓股票行情(无需 Playwright) **方式 B**:portfolio.json 不存在或为空 — 用 Playwright 获取雪球自选股 + 行情: ```bash node {baseDir}/fetch_timeline.js watchlist_quotes ``` ### 步骤 4:汇总分析 结合大V动态和股票行情数据,按下方报告格式输出。 --- ## 报告输出格式 严格按以下五段式结构输出: --- ### 一、大V观点摘要 按人分组,每人包含: - **大V昵称**(标签来自 watchlist.json 的 note 字段) - 每条帖子提炼 1-2 句核心观点,用表格展示(含互动数据) - 汇总该大V提及的具体**股票代码**或**板块方向** ### 二、自选股行情概览 按市场分组(港股 / 美股 / A股),用 Markdown 表格展示: | 股票 | 代码 | 现价 | 涨跌幅 | PE(TTM) | 市值 | |------|------|-----:|-------:|--------:|-----:| 如果有 portfolio.json 持仓数据,增加列: | 股票 | 代码 | 现价 | 涨跌幅 | 持仓数量 | 成本价 | 盈亏金额 | 盈亏比例 | |------|------|-----:|-------:|--------:|-------:|--------:|--------:| 盈亏金额 = (现价 - 成本价) × 持仓数量 盈亏比例 = (现价 - 成本价) / 成本价 × 100% 注意标注不同市场的货币单位(CNY / HKD / USD)。 ### 三、大V观点与持仓关联分析 - 逐一检查大V帖子中是否**直接提及**用户自选股中的股票代码或公司名 - 检查是否提及相关**板块**(如科技、消费、新能源、金融等) - 对每个关联标出**利好/利空**信号 - 指出大V之间的观点**共识或分歧** ### 四、投资参考建议 基于以上分析给出个性化参考: - 自选股中当日**涨跌幅异常**的标的(>3% 或 <-3%)的可能原因 - 大V共识性看好的机会 - 需要关注的风险点 - 可能的操作思路(仅供参考) ### 五、免责声明 > 以上内容由 AI 基于雪球公开信息自动生成,不构成任何投资建议。投资有风险,决策需谨慎。数据可能存在延迟,请以实际行情为准。大V观点仅代表其个人看法。 --- ## 错误处理 | 错误场景 | 检测方式 | 处理 | |---------|---------|------| | Token 未设置 | `$XQ_A_TOKEN` 为空 | 提示用户设置并说明获取方法 | | Playwright 未安装 | node 报 MODULE_NOT_FOUND | 提示运行 `bash {baseDir}/install.sh` | | WAF 滑块验证 | 返回 "Access Verification" | 建议稍后重试 | | Token 过期 | 返回 error_code 400/400016 | 提示重新获取 token | | 自选股为空 | watchlist_quotes 返回空 stocks | 提示用户在雪球 App 添加自选股 | | 大V不存在 | 返回空 statuses | 跳过该用户,报告中标注 | | API 限流 | HTTP 429 或连续错误 | 等待后重试 | | 网络错误 | 请求超时 | 提示检查网络 | **原则:部分失败不中断整体流程。** 大V动态失败仍输出行情报告,行情失败仍输出大V摘要。 --- ## 详细 API 参考 如需了解 API 完整参数、响应结构、股票代码规范、错误码等,参阅 `{baseDir}/references/api-reference.md`。README.md3.0 KBb2c46b3a94f1upstream ↗
# snow-summary [OpenClaw](https://openclaw.ai) Skill — snow大V动态汇总与投资建议 自动抓取snow大V最新发帖 + 用户自选股实时行情,给出汇总摘要和投资参考建议。 ## 功能 - 抓取关注的snow大V最新原创动态(Playwright + stealth 绕过 WAF) - 获取snow自选股列表及实时行情(支持 A 股 / 港股 / 美股) - 可选配置本地持仓,自动计算盈亏 - 输出五段式投资分析报告(大V观点摘要 → 行情概览 → 关联分析 → 投资建议 → 免责声明) ## 安装 ### 1. 放到 OpenClaw skills 目录 ```bash # 克隆到 OpenClaw workspace skills 目录 git clone https://github.com/YOUR_USERNAME/xueqiu-summary.git \ ~/.openclaw/workspace/skills/xueqiu-summary ``` ### 2. 安装依赖 ```bash cd ~/.openclaw/workspace/skills/xueqiu-summary bash install.sh ``` 或手动安装: ```bash npm install npx playwright install chromium ``` ### 3. 设置snow Token ```bash export XQ_A_TOKEN="your_xq_a_token_here" ``` 获取方式:浏览器打开 [xueqiu.com](https://xueqiu.com) → 登录 → F12 → Application → Cookies → 复制 `xq_a_token` 值。 ### 4. 配置关注列表 ```bash cp watchlist.example.json watchlist.json # 编辑 watchlist.json,添加你关注的大V ``` 可选 — 配置持仓(用于计算盈亏): ```bash cp portfolio.example.json portfolio.json # 编辑 portfolio.json,填入你的持仓信息 ``` 如果不配置 `portfolio.json`,会自动从snow账号获取自选股列表。 ## 使用 在 OpenClaw 对话中直接触发即可,agent 会自动识别该 skill 并执行数据抓取和分析。 也可以单独运行脚本: ```bash # 获取大V动态 node fetch_timeline.js timeline "1247347556,5819606767" 5 # 获取自选股列表 node fetch_timeline.js watchlist # 获取自选股 + 实时行情 node fetch_timeline.js watchlist_quotes ``` ## 文件结构 ``` xueqiu-summary/ ├── SKILL.md # OpenClaw skill 定义(agent 读取此文件) ├── fetch_timeline.js # 数据抓取脚本(Playwright + stealth) ├── install.sh # 一键安装依赖 ├── package.json # npm 依赖声明 ├── watchlist.example.json # 大V关注列表示例 ├── portfolio.example.json # 持仓配置示例 ├── references/ │ └── api-reference.md # 雪球 API 参考文档 ├── LICENSE └── README.md ``` ## 技术说明 | 数据 | 接口 | 方式 | 原因 | |------|------|------|------| | 大V动态 | xueqiu.com | Playwright + stealth | 主域名有阿里云 WAF | | 自选股列表 | stock.xueqiu.com | Playwright (browser fetch) | 需浏览器上下文携带 cookie | | 单只股票行情 | stock.xueqiu.com | curl | 子域名无 WAF | ## 免责声明 本项目仅供学习和个人使用。雪球 API 为非官方接口,请遵守雪球的使用条款。投资有风险,AI 生成的分析内容不构成任何投资建议。 ## License MITreferences/api-reference.md6.9 KBc33453b24d28upstream ↗
# 雪球 API 参考文档 ## 认证机制 雪球没有官方公开 API,以下接口为社区逆向所得,基于 Cookie 认证。 ### Token 获取 1. 浏览器打开 https://xueqiu.com/ 2. 登录你的雪球账号 3. 按 F12 打开 DevTools 4. 切换到 Application(应用)标签页 5. 左侧选择 Cookies → `https://xueqiu.com` 6. 找到 `xq_a_token`,复制其值 7. 在终端中设置:`export XQ_A_TOKEN="复制的值"` ### Token 有效期 - Token 通常有效期较长(数周到数月) - 如果退出登录或清除浏览器 Cookie,Token 会失效 - 失效后需重新登录并获取新 Token ### 请求头要求 所有 API 请求必须携带以下头: ``` Cookie: xq_a_token={token} User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Referer: https://xueqiu.com/ ``` --- ## API 接口 ### 1. 用户动态 (User Timeline) 获取指定用户的发帖列表。 **请求** ``` GET https://xueqiu.com/v4/statuses/user_timeline.json ``` **参数** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | user_id | string | 是 | 用户 ID,从个人主页 URL 获取:`xueqiu.com/u/{user_id}` | | type | int | 否 | 帖子类型。`0`=全部(默认),`10`=仅原创,`11`=仅转发 | | count | int | 否 | 每页条数,默认 10,最大 20 | | page | int | 否 | 页码,从 1 开始,默认 1 | **响应结构** ```json { "statuses": [ { "id": 123456789, "user_id": 1247347556, "title": "帖子标题(可能为空)", "text": "<p>帖子正文,包含 HTML 标签</p>", "description": "纯文本摘要", "target": "https://xueqiu.com/1247347556/123456789", "created_at": 1708416000000, "reply_count": 150, "retweet_count": 80, "like_count": 500, "view_count": 50000, "reward_count": 5, "retweeted_status": null, "user": { "id": 1247347556, "screen_name": "段永平", "followers_count": 1000000, "friends_count": 50, "status_count": 3000, "verified": true, "verified_description": "知名投资人" } } ], "total": 3000, "page": 1, "maxPage": 300 } ``` **字段说明** - `text`: 帖子正文,包含 HTML 标签,需用 `gsub("<[^>]*>"; "")` 去除 - `created_at`: Unix 毫秒时间戳 - `retweeted_status`: 如果是转发,包含原帖对象;原创为 null - `target`: 帖子的完整 URL --- ### 2. 股票实时行情 (Stock Quote) 批量获取股票实时行情。 **请求** ``` GET https://stock.xueqiu.com/v5/stock/quote.json ``` **参数** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | symbol | string | 是 | 股票代码,多个用逗号分隔,如 `SH600519,00700` | | extend | string | 否 | `detail` 返回详细信息 | **响应结构** ```json { "data": { "items": [ { "market": { "status_id": 5, "region": "CN", "status": "交易中", "time_zone": "Asia/Shanghai" }, "quote": { "symbol": "SH600519", "code": "600519", "name": "贵州茅台", "exchange": "SH", "current": 1756.00, "percent": 1.25, "chg": 21.70, "open": 1740.00, "high": 1765.00, "low": 1735.00, "last_close": 1734.30, "volume": 2500000, "amount": 4380000000, "turnover_rate": 0.20, "market_capital": 2205000000000, "pe_ttm": 32.50, "pe_lyr": 33.10, "pb": 10.50, "eps": 54.03, "dividend_yield": 1.82, "total_shares": 1256200000, "float_shares": 1256200000, "currency": "CNY", "time": 1708416000000 } } ], "items_size": 1 }, "error_code": 0, "error_description": "" } ``` **关键字段** | 字段 | 说明 | |------|------| | current | 最新价 | | percent | 涨跌幅(百分比) | | chg | 涨跌额 | | open | 今开 | | high | 最高 | | low | 最低 | | last_close | 昨收 | | volume | 成交量(股) | | amount | 成交额(元) | | turnover_rate | 换手率 | | market_capital | 总市值 | | pe_ttm | 滚动市盈率 | | pb | 市净率 | | eps | 每股收益 | | dividend_yield | 股息率 | --- ## 股票代码规范 ### A 股 | 交易所 | 前缀 | 示例 | 说明 | |--------|------|------|------| | 上海证券交易所 | SH | SH600519 | 主板 60xxxx | | 上海证券交易所 | SH | SH688001 | 科创板 688xxx | | 深圳证券交易所 | SZ | SZ000001 | 主板 000xxx | | 深圳证券交易所 | SZ | SZ002001 | 中小板 002xxx | | 深圳证券交易所 | SZ | SZ300001 | 创业板 300xxx | | 北京证券交易所 | BJ | BJ830799 | 北交所 8xxxxx | ### 港股 直接使用 5 位数字代码(不足 5 位前面补 0): | 示例 | 说明 | |------|------| | 00700 | 腾讯控股 | | 09988 | 阿里巴巴-SW | | 03690 | 美团-W | | 01810 | 小米集团-W | | 09618 | 京东集团-SW | ### 美股 直接使用股票代码字母: | 示例 | 说明 | |------|------| | AAPL | 苹果 | | BABA | 阿里巴巴 | | PDD | 拼多多 | --- ## 常见错误码 | HTTP 状态码 | error_code | 含义 | 处理方式 | |------------|------------|------|---------| | 200 | 0 | 成功 | 正常处理 | | 200 | 400 | 请求参数错误 | 检查参数格式 | | 400 | - | 请求格式错误 | 检查 URL 和参数 | | 401 | - | 未认证 | Token 缺失,需设置 | | 403 | - | Token 过期或无效 | 重新获取 Token | | 404 | - | 用户或资源不存在 | 检查 user_id 是否正确 | | 429 | - | 请求频率过高 | 等待后重试,建议间隔 1-2 秒 | | 500 | - | 服务器内部错误 | 稍后重试 | ### 典型错误响应 **Token 过期** ```json { "error_description": "遇到错误,请刷新页面或者重新登录帐号后再试", "error_uri": "/v4/statuses/user_timeline.json", "error_code": "400", "error_data": null } ``` **用户不存在** ```json { "statuses": [], "total": 0, "page": 1, "maxPage": 0 } ``` --- ## 帖子链接格式 雪球帖子的 URL 格式为: ``` https://xueqiu.com/{user_id}/{status_id} ``` 例如:`https://xueqiu.com/1247347556/123456789` --- ## 频率限制建议 - 请求间隔建议 >= 1 秒 - 单次会话总请求数建议 <= 20 次 - 如遇 429 响应,等待 5-10 秒后重试 - 行情接口支持批量查询,尽量一次请求多个股票代码以减少请求次数 --- ## 其他有用接口(备用) ### 搜索用户 ``` GET https://xueqiu.com/search/user.json?q={关键词}&count=10&page=1 ``` 可用于帮用户查找大V的 user_id。 ### 股票搜索 ``` GET https://xueqiu.com/search/stock.json?q={关键词}&count=10&page=1 ``` 可用于模糊搜索股票代码。 ### 个股讨论 ``` GET https://xueqiu.com/query/v1/status/stock_timeline.json?symbol={symbol}&count=10&source=all ``` 可用于查看某只股票的最新讨论。fetch_timeline.js7.3 KB4847bd5917feupstream ↗
// fetch_timeline.js — Playwright + Stealth 雪球数据抓取(绕过阿里云 WAF) // // 子命令: // node fetch_timeline.js timeline <user_id1,user_id2,...> [count] 获取大V动态 // node fetch_timeline.js watchlist 获取当前用户自选股列表 // node fetch_timeline.js watchlist_quotes 获取自选股列表 + 实时行情 // // 环境变量: // XQ_A_TOKEN (必须) — 雪球 xq_a_token cookie 值 // XQ_UID (可选) — 雪球用户 ID,不传则从 /user/show.json 自动获取 // // 输出: JSON 到 stdout,日志到 stderr const { chromium } = require('playwright-extra'); const stealth = require('puppeteer-extra-plugin-stealth')(); chromium.use(stealth); const XQ_A_TOKEN = process.env.XQ_A_TOKEN; if (!XQ_A_TOKEN) { console.error(JSON.stringify({ error: 'XQ_A_TOKEN environment variable not set' })); process.exit(1); } const subcommand = process.argv[2] || 'timeline'; async function createBrowser() { const browser = await chromium.launch({ headless: true }); const uid = process.env.XQ_UID || ''; const context = await browser.newContext({ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', viewport: { width: 1920, height: 1080 }, locale: 'zh-CN', timezoneId: 'Asia/Shanghai', }); const cookies = [ { name: 'xq_a_token', value: XQ_A_TOKEN, domain: '.xueqiu.com', path: '/' }, { name: 'xqat', value: XQ_A_TOKEN, domain: '.xueqiu.com', path: '/' }, { name: 'xq_is_login', value: '1', domain: '.xueqiu.com', path: '/' }, ]; if (uid) { cookies.push({ name: 'u', value: uid, domain: '.xueqiu.com', path: '/' }); } await context.addCookies(cookies); const page = await context.newPage(); // 首页通过 WAF console.error('[xueqiu] visiting homepage to pass WAF...'); await page.goto('https://xueqiu.com/', { waitUntil: 'domcontentloaded', timeout: 20000 }); await page.waitForTimeout(4000); console.error('[xueqiu] WAF session established'); return { browser, context, page }; } // ── timeline ────────────────────────────────────────────── async function fetchTimeline() { const userIds = (process.argv[3] || '').split(',').filter(Boolean); const count = process.argv[4] || 5; if (userIds.length === 0) { console.error(JSON.stringify({ error: 'Usage: node fetch_timeline.js timeline <uid1,uid2,...> [count]' })); process.exit(1); } const { browser, page } = await createBrowser(); const results = {}; for (const userId of userIds) { const apiUrl = `https://xueqiu.com/v4/statuses/user_timeline.json?user_id=${userId}&type=10&count=${count}`; try { console.error(`[xueqiu] fetching timeline for ${userId}...`); await page.goto(apiUrl, { waitUntil: 'domcontentloaded', timeout: 15000 }); await page.waitForTimeout(1500); const text = await page.evaluate(() => document.body.innerText); let data; try { data = JSON.parse(text); } catch { results[userId] = { error: 'non_json_response', preview: text.substring(0, 300) }; continue; } if (data.statuses) { results[userId] = { statuses: data.statuses.map(s => ({ id: s.id, user_id: s.user_id, title: s.title || '', text: (s.text || s.description || '').replace(/<[^>]*>/g, '').substring(0, 500), created_at: s.created_at, reply_count: s.reply_count || 0, retweet_count: s.retweet_count || 0, like_count: s.fav_count || s.like_count || 0, })), total: data.total || data.count || 0, }; } else if (data.error_code || data.error_description) { results[userId] = { error: data.error_description || String(data.error_code) }; } else { results[userId] = { error: 'unexpected_format', data }; } } catch (err) { results[userId] = { error: err.message }; } if (userIds.indexOf(userId) < userIds.length - 1) { await page.waitForTimeout(1500); } } console.log(JSON.stringify(results, null, 2)); await browser.close(); } // ── watchlist ───────────────────────────────────────────── async function fetchWatchlist(withQuotes) { const { browser, page } = await createBrowser(); try { // 获取自选股列表(通过 stock.xueqiu.com v5 API,在浏览器上下文内 fetch 以携带 cookie) console.error('[xueqiu] fetching watchlist...'); const watchlistData = await page.evaluate(async () => { const r = await fetch('https://stock.xueqiu.com/v5/stock/portfolio/stock/list.json?pid=-1&category=1&size=200', { credentials: 'include' }); return r.json(); }); if (watchlistData.error_code && watchlistData.error_code !== 0) { console.log(JSON.stringify({ error: watchlistData.error_description || String(watchlistData.error_code) })); await browser.close(); return; } const stocks = (watchlistData.data && watchlistData.data.stocks) || []; console.error(`[xueqiu] found ${stocks.length} stocks in watchlist`); if (!withQuotes) { console.log(JSON.stringify({ stocks: stocks.map(s => ({ symbol: s.symbol, name: s.name, exchange: s.exchange, marketplace: s.marketplace })) }, null, 2)); await browser.close(); return; } // 批量获取行情(stock.xueqiu.com 支持逗号分隔的 symbol 列表) const symbols = stocks.map(s => s.symbol).join(','); console.error(`[xueqiu] fetching quotes for ${stocks.length} symbols...`); const quoteData = await page.evaluate(async (syms) => { const r = await fetch('https://stock.xueqiu.com/v5/stock/batch/quote.json?symbol=' + syms + '&extend=detail', { credentials: 'include' }); return r.json(); }, symbols); const quotes = (quoteData.data && quoteData.data.items) || []; const result = quotes.map(item => ({ symbol: item.quote.symbol, name: item.quote.name, current: item.quote.current, percent: item.quote.percent, chg: item.quote.chg, high: item.quote.high, low: item.quote.low, last_close: item.quote.last_close, pe_ttm: item.quote.pe_ttm, pb: item.quote.pb, dividend_yield: item.quote.dividend_yield, market_capital: item.quote.market_capital, currency: item.quote.currency, exchange: item.quote.exchange, })); console.log(JSON.stringify({ stocks: result }, null, 2)); } catch (err) { console.error(JSON.stringify({ error: err.message })); process.exit(1); } finally { await browser.close(); } } // ── main ────────────────────────────────────────────────── (async () => { switch (subcommand) { case 'timeline': await fetchTimeline(); break; case 'watchlist': await fetchWatchlist(false); break; case 'watchlist_quotes': await fetchWatchlist(true); break; default: console.error(`Unknown subcommand: ${subcommand}. Use: timeline, watchlist, watchlist_quotes`); process.exit(1); } })();install.sh3.0 KBe9eb214c7277upstream ↗
#!/bin/bash # install.sh — 在 Docker 容器内安装 xueqiu-summary skill 的依赖 # 用法: cd /path/to/xueqiu-summary && bash install.sh set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" echo "==> 安装目录: $SCRIPT_DIR" # 检测包管理器 if command -v apt-get &>/dev/null; then PKG_MGR="apt" elif command -v apk &>/dev/null; then PKG_MGR="apk" elif command -v yum &>/dev/null; then PKG_MGR="yum" else PKG_MGR="unknown" fi echo "==> 包管理器: $PKG_MGR" # 1. 安装 Node.js(如果没有) if ! command -v node &>/dev/null; then echo "==> 安装 Node.js..." if [ "$PKG_MGR" = "apt" ]; then apt-get update && apt-get install -y nodejs npm elif [ "$PKG_MGR" = "apk" ]; then apk add --no-cache nodejs npm elif [ "$PKG_MGR" = "yum" ]; then yum install -y nodejs npm else echo "ERROR: 无法自动安装 Node.js,请手动安装" && exit 1 fi fi echo "==> Node $(node -v), npm $(npm -v)" # 2. 安装 Playwright 系统依赖(Chromium 需要的共享库) echo "==> 安装 Chromium 系统依赖..." if [ "$PKG_MGR" = "apt" ]; then apt-get update && apt-get install -y --no-install-recommends \ libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 \ libcups2 libdrm2 libxkbcommon0 libxcomposite1 \ libxdamage1 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 \ libcairo2 libasound2 libatspi2.0-0 libwayland-client0 \ fonts-noto-cjk \ 2>/dev/null || true elif [ "$PKG_MGR" = "apk" ]; then apk add --no-cache \ chromium nss freetype harfbuzz ca-certificates ttf-freefont \ font-noto-cjk \ 2>/dev/null || true fi # 3. 安装 npm 包(在 skill 目录下本地安装) echo "==> 安装 npm 依赖..." cd "$SCRIPT_DIR" [ ! -f package.json ] && npm init -y --silent npm install --save playwright-extra puppeteer-extra-plugin-stealth 2>&1 | tail -3 # 4. 安装 Chromium 浏览器 echo "==> 下载 Chromium..." npx playwright install chromium 2>&1 | tail -5 # Alpine 特殊处理:用系统 Chromium 代替 Playwright 下载的 if [ "$PKG_MGR" = "apk" ] && command -v chromium-browser &>/dev/null; then export PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=$(which chromium-browser) echo "==> Alpine: 使用系统 Chromium: $PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH" fi # 5. 验证 echo "" echo "==> 验证安装..." node -e " const { chromium } = require('playwright-extra'); const stealth = require('puppeteer-extra-plugin-stealth')(); chromium.use(stealth); console.log(' playwright-extra: OK'); console.log(' stealth plugin: OK'); (async () => { try { const browser = await chromium.launch({ headless: true }); console.log(' Chromium launch: OK'); await browser.close(); console.log(''); console.log('==> 全部就绪!'); } catch(e) { console.error(' Chromium launch FAILED:', e.message.substring(0, 200)); console.error(''); console.error(' 如果是 Alpine 容器,试试: export PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=\$(which chromium-browser)'); process.exit(1); } })(); "LICENSE1.0 KB14fac913ccf8upstream ↗
MIT License Copyright (c) 2026 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.package.json533 Bebb150380683upstream ↗
{ "name": "xueqiu-summary", "version": "1.0.0", "description": "OpenClaw skill — 雪球大V动态汇总与投资建议", "main": "fetch_timeline.js", "scripts": { "install-deps": "bash install.sh", "test": "node -e \"require('playwright-extra'); require('puppeteer-extra-plugin-stealth'); console.log('OK')\"" }, "keywords": ["openclaw", "skill", "xueqiu", "stock", "investment"], "license": "MIT", "dependencies": { "playwright-extra": "^4.3.6", "puppeteer-extra-plugin-stealth": "^2.11.2" } }portfolio.example.json340 Bf0935b8bc1d3upstream ↗
{ "updated": "2026-01-01", "positions": [ { "symbol": "SH600519", "name": "贵州茅台", "market": "A", "shares": 100, "cost": 1700.00 }, { "symbol": "00700", "name": "腾讯控股", "market": "HK", "shares": 200, "cost": 350.00 }, { "symbol": "AAPL", "name": "苹果", "market": "US", "shares": 50, "cost": 180.00 } ] }watchlist.example.json228 B76af6d692373upstream ↗
[ { "user_id": "1247347556", "name": "段永平", "note": "价值投资" }, { "user_id": "5819606767", "name": "释老毛", "note": "港股深度" }, { "user_id": "2227798650", "name": "唐朝", "note": "财报分析" } ]
Plain-text copy, no login: /skill-bundles/chenmuwen0930-rgb-openclaw-skill-snowtrace.md