Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Search, analyze, and interact with Xiaohongshu (RedNote/小红书) content via a local MCP server and shell scripts.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
README_CN.md
1# XHS AI Toolkit23<p align="center">4<b>让 AI 读懂你的小红书</b>5</p>67<p align="center">8简体中文 | <a href="README.md">English</a>9</p>1011<p align="center">12<img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg">13<img alt="Platform" src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS-lightgrey.svg">14<img alt="Python" src="https://img.shields.io/badge/python-3.10+-green.svg">15<img alt="MCP" src="https://img.shields.io/badge/MCP-compatible-purple.svg">16</p>1718---1920小红书 AI 工具包 — 把你的收藏变成 AI 的记忆。2122- **MCP 集成** — 通过 AI 助手搜索、浏览、评论小红书23- **热点跟踪** — 自动生成话题报告,含互动数据分析24- **记忆导出** — 将收藏/点赞笔记转为 AI 可搜索的知识库2526基于 [xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp) 和 [XHS-Downloader](https://github.com/JoeanAmier/XHS-Downloader) 构建。2728## 功能特性2930| 功能 | 说明 |31|------|------|32| 搜索内容 | 按关键词搜索小红书笔记 |33| 首页推荐 | 获取首页推荐列表 |34| 帖子详情 | 获取笔记内容、评论、互动数据 |35| 发表评论 | 在笔记下发表评论 |36| 用户主页 | 获取用户资料和笔记列表 |37| 热点跟踪 | 自动生成话题分析报告 |38| 长图导出 | 将帖子导出为带注释的 JPG 长图 |39| 记忆导出 | 导出收藏/点赞为 Markdown 记忆库 |4041## 快速开始4243### 1. 安装 xiaohongshu-mcp4445从 [GitHub Releases](https://github.com/xpzouying/xiaohongshu-mcp/releases) 下载:4647```bash48# Linux x6449wget https://github.com/xpzouying/xiaohongshu-mcp/releases/latest/download/xiaohongshu-mcp-linux-amd64.tar.gz50wget https://github.com/xpzouying/xiaohongshu-mcp/releases/latest/download/xiaohongshu-login-linux-amd64.tar.gz5152# macOS ARM53wget https://github.com/xpzouying/xiaohongshu-mcp/releases/latest/download/xiaohongshu-mcp-darwin-arm64.tar.gz54wget https://github.com/xpzouying/xiaohongshu-mcp/releases/latest/download/xiaohongshu-login-darwin-arm64.tar.gz55```5657解压安装:5859```bash60mkdir -p ~/.local/bin61tar -xzf xiaohongshu-mcp-*.tar.gz -C ~/.local/bin/62tar -xzf xiaohongshu-login-*.tar.gz -C ~/.local/bin/6364cd ~/.local/bin65mv xiaohongshu-mcp-* xiaohongshu-mcp66mv xiaohongshu-login-* xiaohongshu-login67chmod +x xiaohongshu-mcp xiaohongshu-login68```6970### 2. 安装本工具包7172```bash73# 克隆到 OpenClaw workspace74git clone https://github.com/zhjiang22/openclaw-xhs.git75cp -r openclaw-xhs ~/.openclaw/workspace/skills/xiaohongshu7677# 或使用软链接78ln -s /path/to/openclaw-xhs ~/.openclaw/workspace/skills/xiaohongshu7980# 验证安装81cd ~/.openclaw/workspace/skills/xiaohongshu/scripts82./install-check.sh83```8485### 3. 登录获取 Cookies8687**方式一:本地桌面环境**8889```bash90./login.sh # 打开浏览器,用小红书 App 扫码登录91```9293**方式二:Linux 服务器(无桌面)**9495在本地电脑获取 cookies 后复制到服务器:9697```bash98# 本地电脑(有 GUI)99./xiaohongshu-login100# Cookies 保存在 /tmp/cookies.json101102# 复制到服务器103scp /tmp/cookies.json user@server:~/.xiaohongshu/cookies.json104```105106服务启动时会自动检查以下位置的 cookies(按优先级):1071081. 环境变量 `XHS_COOKIES_SRC` 指定的路径1092. `~/cookies.json`1103. `~/.xiaohongshu/cookies.json`111112### 4. 启动服务113114```bash115./start-mcp.sh # headless 模式116./start-mcp.sh --headless=false # 显示浏览器(调试用)117```118119服务监听 `http://localhost:18060/mcp`。120121停止服务:`./stop-mcp.sh`122123#### 服务器部署(无桌面环境)124125在没有图形界面的 Linux 服务器上,`xiaohongshu-mcp` 底层的浏览器需要虚拟显示器才能正常工作。126`start-mcp.sh` 会**自动检测**是否有桌面环境,如果没有则自动启动 Xvfb,你只需提前安装:127128```bash129# Debian/Ubuntu130sudo apt-get install -y xvfb131132# CentOS/RHEL133sudo yum install -y xorg-x11-server-Xvfb134```135136安装后无需额外配置,`start-mcp.sh` 会自动处理:137- 检测 `DISPLAY` 环境变量138- 没有显示器时自动启动 `Xvfb :99`139- `stop-mcp.sh` 停止服务时会一并清理 Xvfb 进程140141> **提示**:如果不安装 Xvfb,登录和搜索功能会失败。参见 [Issue #3](https://github.com/zhjiang22/openclaw-xhs/issues/3)。142143## 使用方法144145### 基础命令146147```bash148./status.sh # 检查登录状态149./search.sh "咖啡" # 搜索内容150./recommend.sh # 获取推荐151./post-detail.sh <id> <token> # 获取帖子详情152./comment.sh <id> <token> "写得真好!" # 发表评论153./user-profile.sh <user_id> <xsec_token> # 获取用户主页154```155156### 热点跟踪157158自动搜索热帖并生成分析报告:159160```bash161./track-topic.sh "DeepSeek" --limit 10162./track-topic.sh "春节旅游" --limit 5 --output report.md163./track-topic.sh "iPhone 16" --limit 5 --feishu # 导出到飞书164```165166报告包含:167- 📊 概览统计(帖子数、点赞数、评论数)168- 📝 热帖详情(标题、作者、正文、热门评论)169- 💬 评论区热点关键词170- 📈 趋势分析171172### MCP 工具清单173174| 工具名 | 描述 |175|--------|------|176| `check_login_status` | 检查登录状态 |177| `search_feeds` | 搜索内容 |178| `list_feeds` | 获取首页推荐 |179| `get_feed_detail` | 获取帖子详情和评论 |180| `post_comment_to_feed` | 发表评论 |181| `user_profile` | 获取用户主页 |182| `like_feed` | 点赞/取消 |183| `favorite_feed` | 收藏/取消 |184| `publish_content` | 发布图文笔记 |185| `publish_with_video` | 发布视频笔记 |186187### 通用 MCP 调用188189```bash190./mcp-call.sh # 查看可用工具191./mcp-call.sh search_feeds '{"keyword": "咖啡"}'192./mcp-call.sh like_feed '{"feed_id": "xxx", "xsec_token": "xxx", "like": true}'193```194195### 长图导出196197将搜索结果或帖子详情导出为带文字注释的 JPG 长图:198199```bash200# 准备 posts.json(搜索+拉详情后整理)201cat > posts.json << 'EOF'202[203{204"title": "帖子标题",205"author": "作者名",206"stats": "1.3万赞 100收藏",207"desc": "正文摘要",208"images": ["https://...webp"],209"per_image_text": {"1": "第2张图的专属说明"}210}211]212EOF213214./export-long-image.sh --posts-file posts.json -o output.jpg215```216217依赖:Python 3.10+、Pillow(`pip install Pillow`)218219## 记忆导出:把收藏变成 AI 的记忆220221将你的收藏/点赞笔记导出为 AI 可搜索的知识库,让 AI 更懂你。222223### 1. 安装 XHS-Downloader224225```bash226git clone https://github.com/JoeanAmier/XHS-Downloader.git227cd XHS-Downloader228pip install -r requirements.txt229```230231### 2. 获取收藏/点赞链接(油猴脚本)232233手动复制链接效率太低,推荐使用油猴脚本批量提取:234235**安装脚本:**2362371. 安装 [Tampermonkey](https://www.tampermonkey.net/) 浏览器扩展2382. 安装用户脚本:[XHS-Downloader.js](https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/refs/heads/master/static/XHS-Downloader.js)239240**提取链接:**2412421. 打开 [小红书网页版](https://www.xiaohongshu.com) 并登录2432. 进入个人主页 → **收藏** 或 **点赞** 页面2443. 点击 Tampermonkey 图标,选择:245- `提取收藏作品链接`246- `提取点赞作品链接`2474. 脚本会自动滚动页面加载全部内容2485. 提取完成后链接自动复制到剪贴板2496. 粘贴到 `links.md` 文件250251> **注意**:自动滚动功能默认关闭,需在脚本设置中手动开启。开启后可能触发风控,建议适度使用。252253### 3. 批量下载并导出254255```bash256# 复制工具脚本到 XHS-Downloader 目录257cp tools/xhs-downloader/*.py /path/to/XHS-Downloader/258259# 批量下载260cd /path/to/XHS-Downloader261python batch_download.py links.md262263# 导出为多文件(推荐)264python export_to_workspace.py265# 输出到 ~/.openclaw/workspace/xhs-memory/266267# 或导出为单文件268python export_memory.py269# 生成 xhs_memory.md270```271272### 4. 配置 OpenClaw 记忆搜索273274编辑 `~/.openclaw/openclaw.json`:275276```json277{278"memorySearch": {279"extraPaths": [280"~/.openclaw/workspace/xhs-memory"281]282}283}284```285286现在你的 AI 助手可以搜索你的小红书收藏了!287288## 安全说明289290本项目在脚本安全方面采取了以下措施:291292- **Cookies 保护**:cookies 文件复制时自动设置 `600` 权限(仅当前用户可读写)293- **防注入**:所有 shell 脚本使用 `jq` 构建 JSON payload,不通过字符串拼接,防止 shell 注入攻击294- **工具名校验**:MCP 工具名限制为字母数字和下划线,拒绝非法字符295- **路径校验**:跨 skill 调用时校验目标路径在允许的目录范围内296- **第三方内容**:从小红书获取的内容为用户生成内容(UGC),请注意甄别297298299## 注意事项3003011. **发布限制**302- 标题最多 20 个字符303- 正文最多 1000 个字符304- 每日发布上限约 50 条3053062. **账号安全**307- 避免多设备同时登录同一账号308- 手机 App 仅用于查看,不要同时操作3093103. **首次运行**311- 会自动下载 headless 浏览器(约 150MB)312- 请确保网络畅通3133144. **Cookies 有效期**315- 通常有效期约 30 天316- 失效后需重新获取317318## 项目结构319320```321openclaw-xhs/322├── README.md # 英文文档323├── README_CN.md # 中文文档324├── LICENSE325├── SKILL.md # Skill 描述文件326├── scripts/ # MCP 调用脚本327│ ├── install-check.sh328│ ├── start-mcp.sh329│ ├── stop-mcp.sh330│ ├── login.sh331│ ├── mcp-call.sh332│ ├── status.sh333│ ├── search.sh334│ ├── recommend.sh335│ ├── post-detail.sh336│ ├── comment.sh337│ ├── user-profile.sh338│ ├── track-topic.sh339│ ├── track-topic.py340│ ├── export-long-image.sh341│ └── export-long-image.py342└── tools/343└── xhs-downloader/ # 记忆导出工具344├── README.md345├── batch_download.py346├── export_memory.py347└── export_to_workspace.py348```349350## 声明351352本项目是 [xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp) 的**调用封装层**。353354- **不包含** xiaohongshu-mcp 的任何源代码355- **用户需自行下载** xiaohongshu-mcp 二进制文件356- 脚本仅通过 HTTP 协议与 MCP 服务通信357358## 致谢359360- [@xpzouying](https://github.com/xpzouying) — [xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp)361- [@JoeanAmier](https://github.com/JoeanAmier) — [XHS-Downloader](https://github.com/JoeanAmier/XHS-Downloader) (GPL-3.0)362363## License364365MIT License(仅限本项目脚本)366367**注意:** xiaohongshu-mcp 项目未声明开源许可证,请遵守其作者的使用条款。368369---370371<p align="center">372<b>觉得有用?给个 ⭐ 支持一下!</b>373</p>374