Search, read, analyze, and automate Xiaohongshu (小红书) content via CLI
$npx -y skills add lucasygu/redbook --skill redbookInstalls into the current project.
Run `npx skills use "https://github.com/lucasygu/redbook" --skill "lucasygu/redbook"` and follow the generated skill instructions now. Read its complete output, redirecting it to a temporary file first if necessary. Resolve relative paths from the supporting-files directory it provides.
Use the skills in "https://github.com/lucasygu/redbook" that are relevant to the current task. Run `npx skills add "https://github.com/lucasygu/redbook"` and select the relevant skills, then follow their instructions.
| 1 | # redbook — 小红书命令行工具 |
| 2 | |
| 3 | 小红书 CLI 工具:搜索笔记、阅读内容、分析博主、发布图文。使用浏览器 Cookie 认证,无需 API Key。 |
| 4 | |
| 5 | [English](#english) | 中文 |
| 6 | |
| 7 | > ### 最快上手方式 |
| 8 | > |
| 9 | > 把这段话发给你的 AI 助手(Claude Code、Cursor、Codex、Windsurf、OpenClaw 等): |
| 10 | > |
| 11 | > **"帮我用 npm 安装 `@lucasygu/redbook` 这个小红书 CLI 工具,然后运行 `redbook whoami` 验证是否能正常连接。GitHub 地址:https://github.com/lucasygu/redbook"** |
| 12 | > |
| 13 | > OpenClaw 用户也可以直接:**`clawhub install redbook`** |
| 14 | > |
| 15 | > AI 会自动完成安装、验证连接、处理可能的 Cookie 问题。你只需要确保已在 Chrome 中登录 xiaohongshu.com。 |
| 16 | > |
| 17 | > 安装完成后,试试:**"帮我分析'AI编程'这个话题在小红书上的竞争格局"** —— AI 会自动搜索关键词、分析互动数据、发现头部博主、给出内容建议。 |
| 18 | |
| 19 | ## 安装 |
| 20 | |
| 21 | ```bash |
| 22 | npm install -g @lucasygu/redbook |
| 23 | # 或通过 ClawHub(OpenClaw 生态) |
| 24 | clawhub install redbook |
| 25 | ``` |
| 26 | |
| 27 | 需要 Node.js >= 22。支持 **macOS、Windows、Linux**。使用 Chrome 浏览器的 Cookie —— 请先在 Chrome 中登录 xiaohongshu.com。 |
| 28 | |
| 29 | 安装后运行 `redbook whoami` 验证连接。CLI 会自动检测所有 Chrome 配置文件,找到你的小红书登录状态。 |
| 30 | |
| 31 | - **macOS** —— 如果遇到钥匙串弹窗,请点击"始终允许" |
| 32 | - **Windows** —— Chrome 127+ 使用了 App-Bound Encryption,CLI 会自动启动 Chrome headless 模式读取 Cookie(需要先关闭 Chrome)。如果自动提取失败,可以用 `--cookie-string` 手动传入 |
| 33 | |
| 34 | ## 能做什么 |
| 35 | |
| 36 | - **话题研究** —— 搜索关键词,分析哪些话题有流量、哪些是蓝海 |
| 37 | - **竞品分析** —— 找到头部博主,对比粉丝量、互动数据、内容风格 |
| 38 | - **爆款拆解** —— 分析爆款笔记的标题钩子、互动比例、评论主题 |
| 39 | - **爆款模板** —— 从多篇爆款笔记提取内容模板(标题结构、正文结构、钩子模式) |
| 40 | - **限流检测** —— 检测笔记是否被隐形限流(通过创作者后台 API 的隐藏 level 字段) |
| 41 | - **收藏专辑** —— 查看收藏专辑内容,分析专辑内的笔记 |
| 42 | - **收藏管理** —— 查看收藏列表、收藏/取消收藏笔记(支持自己和其他用户的公开收藏) |
| 43 | - **评论管理** —— 发评论、回复评论、按策略批量回复(问题优先 / 高赞优先 / 未回复优先) |
| 44 | - **图文卡片** —— Markdown 渲染为小红书风格的 PNG 图文卡片(7 种配色主题) |
| 45 | - **内容策划** —— 基于数据发现内容机会,生成有数据支撑的选题建议 |
| 46 | - **受众洞察** —— 从互动信号推断目标用户画像 |
| 47 | |
| 48 | 通过 AI 助手使用时,这些工作流可以自动串联完成。直接使用 CLI 时,每个命令也可以独立运行。 |
| 49 | |
| 50 | ## 快速开始 |
| 51 | |
| 52 | ```bash |
| 53 | # 检查连接 |
| 54 | redbook whoami |
| 55 | |
| 56 | # 搜索笔记 |
| 57 | redbook search "AI编程" --sort popular |
| 58 | |
| 59 | # 阅读笔记 |
| 60 | redbook read https://www.xiaohongshu.com/explore/abc123 |
| 61 | |
| 62 | # 获取评论 |
| 63 | redbook comments https://www.xiaohongshu.com/explore/abc123 --all |
| 64 | |
| 65 | # 浏览推荐页 |
| 66 | redbook feed |
| 67 | |
| 68 | # 查看博主信息 |
| 69 | redbook user "<profileUrl>" |
| 70 | redbook user-posts "<profileUrl>" |
| 71 | redbook account-report --file kos-accounts.txt --month 2026-07 --json |
| 72 | |
| 73 | # 搜索话题标签 |
| 74 | redbook topics "Claude Code" |
| 75 | |
| 76 | # 查看收藏(默认当前用户) |
| 77 | redbook favorites --json |
| 78 | redbook favorites <userId> --json --all |
| 79 | |
| 80 | # 收藏/取消收藏 |
| 81 | redbook collect "<noteUrl>" |
| 82 | redbook uncollect "<noteUrl>" |
| 83 | |
| 84 | # 分析爆款笔记 |
| 85 | redbook analyze-viral https://www.xiaohongshu.com/explore/abc123 |
| 86 | |
| 87 | # 从多篇爆款提取内容模板 |
| 88 | redbook viral-template "<url1>" "<url2>" "<url3>" --json |
| 89 | |
| 90 | # 发评论 |
| 91 | redbook comment "<noteUrl>" --content "写得好!" |
| 92 | |
| 93 | # 回复评论 |
| 94 | redbook reply "<noteUrl>" --comment-id "<id>" --content "感谢提问!" |
| 95 | |
| 96 | # 按策略批量回复(先预览再执行) |
| 97 | redbook batch-reply "<noteUrl>" --strategy questions --dry-run |
| 98 | redbook batch-reply "<noteUrl>" --strategy questions --template "感谢!{content}" --max 10 |
| 99 | |
| 100 | # 查看收藏专辑 |
| 101 | redbook boards # 列出自己的专辑 |
| 102 | redbook boards <userId> # 列出他人的专辑 |
| 103 | redbook board "https://www.xiaohongshu.com/board/abc123" |
| 104 | redbook board abc123 --json |
| 105 | |
| 106 | # 检测笔记限流状态 |
| 107 | redbook health |
| 108 | redbook health --all --json |
| 109 | |
| 110 | # 将 Markdown 渲染为图文卡片(需要可选依赖) |
| 111 | redbook render content.md --style xiaohongshu |
| 112 | redbook render content.md --style dark --output-dir ./cards |
| 113 | |
| 114 | # 发布图文笔记 |
| 115 | redbook post --title "标题" --body "正文内容" --images cover.png |
| 116 | redbook post --title "测试" --body "..." --images img.png --private |
| 117 | ``` |
| 118 | |
| 119 | ## 命令一览 |
| 120 | |
| 121 | | 命令 | 说明 | |
| 122 | |------|------| |
| 123 | | `whoami` | 查看当前登录账号 | |
| 124 | | `search <关键词>` | 搜索笔记 | |
| 125 | | `read <url>` | 阅读单篇笔记 | |
| 126 | | `comments <url>` | 获取笔记评论 | |
| 127 | | `user <userId\|profileUrl>` | 查看用户资料 | |
| 128 | | `user-posts <userId\|profileUrl>` | 列出用户所有笔记 | |
| 129 | | `account-report <user...>` | 批量统计账号发帖和互动数据 | |
| 130 | | `feed` | 获取推荐页内容 | |
| 131 | | `post` | 发布图文笔记(易触发验证码,详见下方说明) | |
| 132 | | `topics <关键词>` | 搜索话题/标签 | |
| 133 | | `favorites [userId]` | 查看收藏笔记列表(默认当前用户) | |
| 134 | | `collect <url>` | 收藏(书签)笔记 | |
| 135 | | `uncollect <url>` | 取消收藏笔记 | |
| 136 | | `health` | 检测笔记隐形限流(通过创作者后台隐藏 level 字段) | |
| 137 | | `boards [userId]` | 列出用户的收藏专辑(默认当前用户) | |
| 138 | | `board <url>` | 查看收藏专辑内容(接受专辑 URL 或 ID) | |
| 139 | | `analyze-viral <url>` | 分析爆款笔记(钩子、互动、结构) | |
| 140 | | `viral-template <url...>` | 从 1-3 篇爆款笔记提取内容模板 | |
| 141 | | `comment <url>` | 发表评论 | |
| 142 | | `reply <url>` | 回复指定评论 | |
| 143 | | `batch-reply <url>` | 按策略批量回复评论(支持预览模式) | |
| 144 | | `render <文件>` | Markdown 渲染为小红书图文卡片 PNG(需可选依赖) | |
| 145 | | `auth` | 保存、导出、检查 Cookie 文件,适合云端/OpenClaw 使用 | |
| 146 | |
| 147 | ### 通用选项 |
| 148 | |
| 149 | | 选项 | 说明 | 默认值 | |
| 150 | |------|------|--------| |
| 151 | | `--cookie-source <浏 |