git:20260706.2c40f31 to git:20260823.44495c8

65 added, 277 removed. Audit A to A.

What this update changes in the checks

No check changed: every fixed check gives the same answer before and after this update.

A tripped check is a label, not a verdict: read the matched text and the lines below. This week's updates that newly trip a check.

---
name: xiaohongshu-skill
- description: 小红书 / Xiaohongshu / RedNote AI Agent Skill。用 Python Playwright 搜笔记、读详情、抓推荐流、发图文/视频/长文/Markdown、评论点赞收藏、二维码登录、模板、策略和 SOP;默认 JSON 输出,写操作必须用户确认。适合 Claude Code、Codex、OpenClaw、ClawHub、skills.sh、Hermes Agent 和 AgentSkills。用户提到 xiaohongshu、小红书、rednote、RED、小红书搜索、发到小红书、小红书笔记分析、小红书运营、小红书自动化时触发。
- user-invokable: true
- metadata: {"openclaw": {"emoji": "📕", "requires": {"bins": ["python3", "playwright"], "anyBins": ["python3", "python"]}, "os": ["win32", "linux", "darwin"], "install": [{"id": "pip", "kind": "node", "label": "Install dependencies (pip)", "bins": ["playwright"]}]}}
+ description: 小红书 / Xiaohongshu / RedNote AI Agent Skill。用 Python Playwright 搜索和读取内容、管理登录会话、发布图文/视频/长文、评论、点赞和收藏;默认输出 JSON,任何写操作都必须先获得用户确认。用户提到 xiaohongshu、小红书、rednote、小红书搜索、发到小红书、小红书笔记分析、小红书运营或小红书自动化时触发。
+ license: MIT
+ compatibility: Requires Python 3.10 or newer and Playwright Chromium. Supports Windows, macOS, and Linux.
+ metadata:
+ openclaw:
+ emoji: "📕"
+ requires:
+ anyBins:
+ - python3
+ - python
+ os:
+ - win32
+ - linux
+ - darwin
---
# 小红书 Skill
- 用 Python Playwright 驱动浏览器操作小红书。数据从 `window.__INITIAL_STATE__`(Vue SSR 状态对象)里取。搜索、发布、互动、运营全在这。
-
- ## 写操作安全规则
-
- 下面这些命令会真的改动账号数据。跑之前**必须**让用户确认:
-
- 1. **发布笔记** -- 先展示标题、正文、图片列表。用户说"发"才发。
- 2. **评论/回复** -- 先展示要发出去的内容。用户说"发"才发。
- 3. **点赞/收藏** -- 先展示目标帖子。用户说"行"才执行。
-
- 用 `AskUserQuestion` 弹确认框。别自己决定。
-
- ## 前置条件
-
- 在 `{baseDir}` 目录装依赖:
-
- ```bash
- cd {baseDir}
- pip install -r requirements.txt
- playwright install chromium
- ```
-
- Linux/WSL 还要跑:
-
- ```bash
- playwright install-deps chromium
- ```
-
- ## 快速开始
-
- 所有命令从 `{baseDir}` 目录跑。
-
- ### 1. 登录(第一次必须做)
-
- ```bash
- cd {baseDir}
-
- # 弹出浏览器窗口,显示二维码,用微信或小红书 App 扫
- python -m scripts qrcode --headless=false
-
- # 检查登录还在不在
- python -m scripts check-login
- ```
-
- 无头环境里二维码存到 `{baseDir}/data/qrcode.png`。传给别人扫也行。
-
- ### 2. 搜索
-
- ```bash
- cd {baseDir}
-
- # 基本搜索
- python -m scripts search "关键词"
-
- # 带条件
- python -m scripts search "美食" --sort-by=最新 --note-type=图文 --limit=10
- ```
-
- **筛选选项:**
-
- - `--sort-by`:综合、最新、最多点赞、最多评论、最多收藏
- - `--note-type`:不限、视频、图文
- - `--publish-time`:不限、一天内、一周内、半年内
- - `--search-scope`:不限、已看过、未看过、已关注
- - `--location`:不限、同城、附近
-
- ### 3. 帖子详情
-
- ```bash
- cd {baseDir}
-
- # 用搜索结果里的 id 和 xsec_token
- python -m scripts feed <feed_id> <xsec_token>
-
- # 同时加载评论
- python -m scripts feed <feed_id> <xsec_token> --load-comments --max-comments=20
- ```
-
- ### 4. 用户主页
-
- ```bash
- cd {baseDir}
-
- # 看别人的主页
- python -m scripts user <user_id> [xsec_token]
-
- # 看自己的主页
- python -m scripts me
- ```
-
- ### 5. 评论互动
-
- **先确认再发。** 跑之前用 `AskUserQuestion` 把评论内容亮出来让用户确认。
-
- ```bash
- cd {baseDir}
-
- # 发评论
- python -m scripts comment <feed_id> <xsec_token> --content="好棒的笔记!"
-
- # 回复别人的评论
- python -m scripts reply <feed_id> <xsec_token> --comment-id=<comment_id> --reply-user-id=<user_id> --content="感谢分享"
-
- # 通过通知页回复(更安全)
- python -m scripts reply-notification --content="谢谢关注" --index=0
- ```
-
- ### 6. 点赞 / 收藏
-
- **先确认再操作。** 用 `AskUserQuestion` 把目标帖子亮出来让用户确认。
-
- ```bash
- cd {baseDir}
-
- # 点赞 / 取消
- python -m scripts like <feed_id> <xsec_token>
- python -m scripts unlike <feed_id> <xsec_token>
-
- # 收藏 / 取消
- python -m scripts collect <feed_id> <xsec_token>
- python -m scripts uncollect <feed_id> <xsec_token>
- ```
-
- ### 7. 首页推荐流
+ 通过 JSON CLI 操作小红书浏览器会话。执行入口统一为:
```bash
cd {baseDir}
- python -m scripts explore --limit=20
+ uv run python -m scripts <command>
```
- ### 8. 发布笔记
-
- **先确认再发。** 跑之前用 `AskUserQuestion` 把标题、正文、图片亮出来让用户确认。
+ ## 安全规则
- ```bash
- cd {baseDir}
+ 发布、评论、回复、点赞、收藏、取消点赞和取消收藏会改变真实账号状态。执行前必须:
- # 图文笔记(默认停在发布按钮,加 --auto-publish 自动发)
- python -m scripts publish --title="标题" --content="正文" --images="img1.jpg,img2.jpg" --tags="旅行,美食"
+ 1. 展示目标账号、内容、媒体和操作类型。
+ 2. 获得用户明确确认。
+ 3. 只执行用户确认的单次操作。
- # 视频笔记
- python -m scripts publish-video --title="标题" --content="描述" --video="video.mp4" --tags="vlog"
+ 遇到验证码、登录页或安全验证页时停止。不要自动绕过验证,不要运行批量抓取或批量互动。
- # Markdown 渲染成图片再发
- python -m scripts publish-md --title="标题" --file=article.md --tags="干货"
- python -m scripts publish-md --title="标题" --text="# 正文\n内容..." --width=1080
+ ## 任务路由
- # 长文笔记(创作者中心"写长文")
- python -m scripts publish-longform --title="长文标题" --content="长文正文内容..."
+ | 用户目标 | 命令或参考 |
+ | --- | --- |
+ | 首次登录或重新登录 | `qrcode --headless=false` |
+ | 检查登录 | `check-login` |
+ | 管理多个账号 | `--profile <name>`;详见 `docs/INSTALL.md` |
+ | 搜索笔记 | `search` |
+ | 读取笔记详情 | `feed` |
+ | 读取用户主页 | `user` 或 `me` |
+ | 获取推荐流 | `explore` |
+ | 准备或发布图文 | `publish` |
+ | 准备或发布视频 | `publish-video` |
+ | Markdown 转图片发布 | `publish-md` |
+ | 准备或发布长文 | `publish-longform` |
+ | 评论和回复 | `comment`、`reply`、`reply-notification` |
+ | 点赞和收藏 | `like`、`collect`、`unlike`、`uncollect` |
+ | 模板、策略和 SOP | `template`、`strategy-*`、`sop` |
+ | 查看参数 | `python -m scripts <command> --help` |
- # 定时发布
- python -m scripts publish --title="标题" --content="正文" --images="img.jpg" --schedule-time="2025-03-01 12:00"
- ```
+ 完整命令见 `docs/API.md`;安装和平台接入见 `docs/INSTALL.md`、`docs/INTEGRATIONS.md`。
- ### 9. 写作模板
+ ## 初始化
```bash
cd {baseDir}
-
- # 生成模板(标题建议 + 内容框架 + 标签推荐)
- python -m scripts template --topic="旅行攻略"
- python -m scripts template --topic="美食探店" --type=视频
- python -m scripts template --topic="学习方法" --type=长文
+ uv sync --frozen --no-dev
+ uv run playwright install chromium
+ uv run python -m scripts qrcode --headless=false
```
- ### 10. 运营策略
+ 开发者使用:
```bash
- cd {baseDir}
-
- # 设账号定位
- python -m scripts strategy-init --persona="旅行博主" --audience="18-35岁旅行爱好者" --direction="旅行攻略,小众目的地"
-
- # 看当前策略
- python -m scripts strategy-show
-
- # 查今日互动配额
- python -m scripts strategy-check-limit --limit-type=likes
- python -m scripts strategy-check-limit --limit-type=comments
-
- # 加内容日历
- python -m scripts strategy-add-post --date="2025-03-01" --topic="春日出行攻略" --type=图文
+ uv sync --frozen --group dev
+ uv run python -m scripts.quality check
```
- ### 11. SOP 编排
+ ## 只读示例
```bash
- cd {baseDir}
-
- # 发布 SOP(选题分析 -> 内容校验 -> 模板生成 -> 发布准备)
- python -m scripts sop --type=publish --topic="旅行攻略" --note-type=图文
-
- # 推荐流互动 SOP(模拟真人浏览行为)
- python -m scripts sop --type=explore --feed-count=10 --like-prob=0.3 --collect-prob=0.1
-
- # 评论互动 SOP(逐条回复,带配额控制)
- python -m scripts sop --type=comment --replies='[{"feed_id":"abc","xsec_token":"xyz","content":"好棒"}]'
- ```
-
- ## 数据提取路径
-
- | 数据类型 | JavaScript 路径 |
- |----------|----------------|
- | 搜索结果 | `window.__INITIAL_STATE__.search.feeds` |
- | 帖子详情 | `window.__INITIAL_STATE__.note.noteDetailMap` |
- | 互动状态 | `window.__INITIAL_STATE__.note.noteDetailMap[id].note.interactInfo` |
- | 用户信息 | `window.__INITIAL_STATE__.user.userPageData` |
- | 用户笔记 | `window.__INITIAL_STATE__.user.notes` |
- | 推荐流 | `window.__INITIAL_STATE__.feed.feeds` |
-
- **Vue Ref 解包:** 始终用 `.value` 或 `._value`:
-
- ```javascript
- const data = obj.value !== undefined ? obj.value : obj._value;
+ uv run python -m scripts search "咖啡" --limit=5
+ uv run python -m scripts feed <feed_id> <xsec_token>
+ uv run python -m scripts explore --limit=10
```
- ## 反爬保护
-
- 内置多层防护,尽量避免触发验证码:
-
- - **频率控制**:两次导航间自动等 3-6 秒。连续 5 次请求后冷却 10 秒。
- - **真人化延迟**:点击前等 1-2.5s,点击后冷却 5-12s。每 3 次交互批次冷却 15-30s。
- - **真人化发布**:标题填写延迟 0.5-1.5s。正文逐字输入,每字 20-60ms。步骤间隔随机。
- - **频率检测**:自动识别 toast 提示("频繁"、"操作太快"、"稍后再试")。
- - **失败重试**:评论提交失败自动重试一次(间隔 2-4s)。
- - **验证码检测**:检测到安全验证重定向时抛出 `CaptchaError`。
- - **每日配额**:策略模块追踪每天互动次数,防止超。
-
- **触发验证码了怎么办:**
+ `feed_id`、`user_id` 和 `xsec_token` 必须来自当前会话的结果,不要长期缓存。
- 1. 等几分钟再试。
- 2. 跑 `cd {baseDir} && python -m scripts qrcode --headless=false` 手动过验证。
- 3. Cookie 失效了就重新扫码登录。
+ ## 发布语义
- ## 输出格式
+ 发布命令默认填写表单并返回 `ready`。用户确认后才能追加 `--auto-publish`。
- 所有命令输出 JSON。搜索结果长这样:
+ 自动提交可能返回:
- ```json
- {
- "id": "abc123",
- "xsec_token": "ABxyz...",
- "title": "帖子标题",
- "type": "normal",
- "user": "用户名",
- "user_id": "user123",
- "liked_count": "1234",
- "collected_count": "567",
- "comment_count": "89"
- }
- ```
+ - `confirmed`:已观察到可信成功信号。
+ - `submitted_unconfirmed`:已点击提交但未确认成功;必须人工复核,禁止自动重试。
+ - `failed`:提交失败或出现登录、验证码、安全验证等失败信号。
- ## 文件结构
+ ## 输出和错误
- ```
- {baseDir}/
- ├── SKILL.md # 本文件
- ├── README.md # 项目文档
- ├── requirements.txt # Python 依赖
- ├── LICENSE # MIT
- ├── data/ # 运行时数据(二维码、调试输出)
- ├── scripts/ # 核心模块
- │ ├── __init__.py # 模块导出(v1.3.0)
- │ ├── __main__.py # CLI 入口(22+ 子命令)
- │ ├── client.py # 浏览器客户端(频率控制 + 验证码检测)
- │ ├── login.py # 二维码登录流程
- │ ├── search.py # 搜索(多条件筛选)
- │ ├── feed.py # 帖子详情提取
- │ ├── user.py # 用户主页提取
- │ ├── comment.py # 评论(发表/回复/通知页 + 延迟 + 重试)
- │ ├── interact.py # 点赞收藏(延迟 + 频率检测 + 批次冷却)
- │ ├── explore.py # 推荐流提取
- │ ├── publish.py # 发布(图文/视频/Markdown/长文 + 延迟)
- │ ├── templates.py # 写作模板引擎
- │ ├── strategy.py # 运营策略(配额/日历/定位)
- │ ├── selectors.py # 浏览器选择器契约
- │ ├── output_contracts.py # CLI JSON 输出契约
- │ ├── quality.py # 本地和 CI 质量门
- │ └── sop.py # SOP 编排引擎
- └── tests/ # 单元测试
- ├── test_client.py
- ├── test_cli.py
- ├── test_search.py
- ├── test_comment.py
- ├── test_interact.py
- ├── test_publish.py
- ├── test_output_contracts.py
- ├── test_quality.py
- ├── test_selectors.py
- ├── test_templates.py
- ├── test_strategy.py
- └── test_sop.py
- ```
+ 标准输出是 JSON;诊断信息写入标准错误。Agent 应先读取 `status`,再依据 `scripts/output_contracts.py` 中的契约处理字段。
- ## 跨平台兼容
+ 发生 `captcha_required` 或浏览器安全验证时,不要重试循环。切换到有头模式并由用户处理。
- | 环境 | 无头模式 | 有头(扫码登录) | 备注 |
- |------|----------|-----------------|------|
- | Windows | OK | OK | 主力开发环境 |
- | WSL2 (Win11) | OK | 用 WSLg | 需要 `playwright install-deps` |
- | Linux 服务器 | OK | 不适用 | 二维码存图片文件 |
+ ## 本地状态
- ## 注意
+ 每个 profile 独立保存浏览器状态、Cookie 备份和会话元数据。不要读取、展示、提交或外发这些文件。`XHS_FP_SEED` 只用于显式覆盖当前进程的稳定指纹 seed。
- 1. **Cookie 过期**:定期会过期。`check-login` 返回 false 就重新登录。
- 2. **频率限制**:猛抓会出验证码。别关内置频率控制。
- 3. **xsec_token**:跟会话绑定的。始终用搜索结果里最新的。
- 4. **配额管理**:用 `strategy-check-limit` 查剩余配额,别超过。
- 5. **别滥用**:会封号。本工具仅供学习研究用。
+ 安全和隐私规则见 `docs/SECURITY.md`。架构说明见 `docs/ARCHITECTURE.md`。