
Xiaohongshu Workflow
- 30 installs
- 82 repo stars
- Updated August 2, 2026
- aaaaqwq/claude-code-skills
xiaohongshu-workflow is a Claude Code skill that runs a full Xiaohongshu (RED) operations workflow for publishing, topic tracking, engagement, and analytics.
About
xiaohongshu-workflow is a Claude Code skill for operating a Xiaohongshu (RED) account end to end. It covers MCP server setup and cookie login, publishing image and video notes, tracking trending topics, managing comment replies, and generating analytics reports. A developer uses it to automate content marketing on Xiaohongshu. It bundles many shell scripts and reference docs built on the xiaohongshu-mcp project.
- End-to-end Xiaohongshu ops via the xiaohongshu-mcp server
- Publishes image/text notes and tracks trending topics
- Includes scripts for search, comment, and analytics reports
Xiaohongshu Workflow by the numbers
- 30 all-time installs (skills.sh)
- Ranked #604 of 853 Sales & Marketing skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
xiaohongshu-workflow capabilities & compatibility
- Capabilities
- social publishing · trend tracking · engagement management
- Use cases
- marketing · web scraping
What xiaohongshu-workflow says it does
基于 [xiaohongshu-mcp](https://github.com/xpzouying/xiaohongshu-mcp) 构建的完整运营工作流。
Cookies 有效期约 30 天
npx skills add https://github.com/aaaaqwq/claude-code-skills --skill xiaohongshu-workflowAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 30 |
|---|---|
| repo stars | ★ 82 |
| Last updated | August 2, 2026 |
| Repository | aaaaqwq/claude-code-skills ↗ |
What it does
Run a full Xiaohongshu (RED) operations workflow: account login, publishing notes, topic tracking, comment replies, and analytics.
When should I use this skill?
When configuring, publishing to, or analyzing a Xiaohongshu (RED) account.
What you get
- Published notes
- Topic tracking reports
- Analytics
By the numbers
- title <=20 chars, body <=1000 chars, up to 18 images
- <=50 posts per day
Files
小红书全流程运营工作流
基于 xiaohongshu-mcp 构建的完整运营工作流。
工作流决策树
用户请求
├── 配置/登录 → 【账号配置】
├── 发布内容 → 【内容发布】
├── 搜索/监控 → 【热点追踪】
├── 互动管理 → 【互动管理】
└── 数据分析 → 【数据分析】1. 账号配置
1.1 安装 MCP 服务
# 下载 xiaohongshu-mcp(Linux x64)
wget https://github.com/xpzouying/xiaohongshu-mcp/releases/latest/download/xiaohongshu-mcp-linux-amd64.tar.gz
wget https://github.com/xpzouying/xiaohongshu-mcp/releases/latest/download/xiaohongshu-login-linux-amd64.tar.gz
# 解压到 ~/.local/bin
mkdir -p ~/.local/bin
tar -xzf xiaohongshu-mcp-*.tar.gz -C ~/.local/bin/
tar -xzf xiaohongshu-login-*.tar.gz -C ~/.local/bin/
# 重命名并添加执行权限
cd ~/.local/bin
mv xiaohongshu-mcp-* xiaohongshu-mcp
mv xiaohongshu-login-* xiaohongshu-login
chmod +x xiaohongshu-mcp xiaohongshu-login1.2 登录获取 Cookies
方式一:本地桌面环境
xiaohongshu-login # 打开浏览器,用小红书 App 扫码登录方式二:Linux 服务器(无桌面)
在本地电脑(Windows/Mac)获取 cookies:
# 下载 Windows 版本
wget https://github.com/xpzouying/xiaohongshu-mcp/releases/latest/download/xiaohongshu-login-windows-amd64.zip
unzip xiaohongshu-login-windows-amd64.zip
# 运行登录
.\xiaohongshu-login-windows-amd64.exe
# Cookies 保存在 C:\Users\<用户名>\AppData\Local\Temp\cookies.json
# 复制到服务器
scp /mnt/c/Users/<用户名>/AppData/Local/Temp/cookies.json user@server:~/.xiaohongshu/1.3 启动 MCP 服务
# 启动服务(headless 模式)
xiaohongshu-mcp
# 检查状态
curl http://localhost:18060/mcp
# 查看日志
tail -f ~/.xiaohongshu/mcp.log1.4 配置到 OpenClaw
将 skill 目录链接到 OpenClaw workspace:
ln -s /path/to/xiaohongshu-workflow ~/.openclaw/workspace/skills/xiaohongshu-workflow---
2. 内容发布
2.1 发布流程
策划主题 → 收集素材 → 撰写内容 → 生成图片 → 发布 → 监控2.2 内容规范
| 项目 | 限制 |
|---|---|
| 标题 | ≤20 字符 |
| 正文 | ≤1000 字符 |
| 图片 | 最多 18 张 |
| 视频 | ≤15 分钟 |
| 每日发布 | ≤50 条 |
2.3 发布图文笔记
使用 MCP 工具 publish_content:
# 通过脚本调用
./scripts/publish.sh \
--title "标题" \
--content "正文内容" \
--images "/path/to/image1.jpg,/path/to/image2.jpg" \
--tags "标签1,标签2"Python 调用示例:
import requests
def publish_note(title, content, images, tags=None):
"""发布小红书图文笔记"""
payload = {
"title": title,
"content": content,
"images": images, # 图片路径列表
"tags": tags or []
}
response = requests.post(
"http://localhost:18060/mcp",
json={"tool": "publish_content", "params": payload}
)
return response.json()2.4 内容策略
发布主题类型: 1. 教程类:使用指南、技巧分享 2. 案例类:实际应用、成功故事 3. 热点类:行业动态、趋势分析 4. 互动类:问答、投票、征集
最佳发布时间:
- 工作日:9:00-11:00, 18:00-20:00
- 周末:10:00-12:00, 19:00-21:00
内容质量原则:
- 标题吸引眼球(数字、疑问、感叹)
- 首图决定点击率
- 正文简洁有价值
- 标签精准覆盖
---
3. 热点追踪
3.1 搜索内容
# 通过脚本搜索
./scripts/search.sh "关键词" --limit 20
# MCP 调用
curl -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-d '{"tool": "search_feeds", "params": {"keyword": "关键词", "limit": 20}}'3.2 热点报告生成
# 生成热点追踪报告
./scripts/track-topic.sh "话题" --limit 10 --output report.md报告内容包括:
- 概览统计(帖子数、点赞数、评论数)
- 热帖详情(标题、作者、正文、热门评论)
- 评论区热点关键词
- 趋势分析
3.3 定时监控
配置 OpenClaw Heartbeat 进行定时监控:
# 在 HEARTBEAT.md 中添加
## 小红书监控
**触发条件:** 每 4-6 小时
- [ ] 检查账号帖子表现
- [ ] 搜索相关话题动态
- [ ] 记录数据变化
- [ ] 发现热点时通知---
4. 互动管理
4.1 获取帖子详情
./scripts/post-detail.sh <note_id> <xsec_token>4.2 发表评论
./scripts/comment.sh <note_id> <xsec_token> "评论内容"4.3 回复策略
需要回复:
- 真实提问
- 技术咨询
- 功能建议
- 使用问题
不需要回复:
- 垃圾广告
- 纯表情符号
- 无意义评论
- 重复评论
回复模板:
👋 感谢关注!
[针对问题简要回答]
📚 更多信息:
- 文档:[链接]
- 社区:[链接]
如有其他问题,欢迎继续交流!---
5. 数据分析
5.1 监控指标
| 指标 | 说明 | 监控频率 |
|---|---|---|
| 点赞数 | 用户认可度 | 每日 |
| 收藏数 | 内容价值 | 每日 |
| 评论数 | 互动活跃度 | 每日 |
| 分享数 | 传播范围 | 每日 |
| 粉丝增长 | 账号影响力 | 每周 |
5.2 数据记录格式
{
"history": [
{
"time": "2026-02-17 21:54:46",
"post_id": "xxx",
"title": "帖子标题",
"liked_count": 0,
"comment_count": 0,
"collected_count": 2,
"shared_count": 0
}
]
}5.3 报警规则
- 点赞突增:短时间内 >100
- 评论突增:短时间内 >50
- 收藏突增:短时间内 >20
- 负面评论:检测到负面关键词
---
6. 记忆导出
将小红书收藏/点赞导出为 AI 可搜索的知识库。
6.1 安装 XHS-Downloader
git clone https://github.com/JoeanAmier/XHS-Downloader.git
cd XHS-Downloader
pip install -r requirements.txt6.2 提取收藏链接
1. 安装 Tampermonkey 浏览器扩展 2. 安装用户脚本:XHS-Downloader.js 3. 打开小红书网页版 → 个人主页 → 收藏/点赞 4. 点击 Tampermonkey 图标 → 选择提取链接 5. 粘贴到 links.md 文件
6.3 批量下载导出
# 复制工具脚本到 XHS-Downloader 目录
cp scripts/xhs-downloader/*.py /path/to/XHS-Downloader/
# 批量下载
python batch_download.py links.md
# 导出为 OpenClaw 记忆
python export_to_workspace.py
# 输出到 ~/.openclaw/workspace/xhs-memory/6.4 配置记忆搜索
编辑 ~/.openclaw/openclaw.json:
{
"memorySearch": {
"extraPaths": [
"~/.openclaw/workspace/xhs-memory"
]
}
}---
7. 运营最佳实践
7.1 内容日历
| 星期 | 内容类型 | 发布时间 |
|---|---|---|
| 周一 | 教程/干货 | 9:00 |
| 周三 | 案例分享 | 18:00 |
| 周五 | 热点追踪 | 12:00 |
| 周日 | 互动/问答 | 10:00 |
7.2 账号安全
- 避免多设备同时登录
- 手机 App 仅用于查看
- Cookies 有效期约 30 天
- 定期检查登录状态
7.3 数据驱动优化
1. 记录每篇帖子的数据 2. 分析高表现内容特征 3. 复制成功模式 4. 持续迭代优化
---
资源目录
scripts/
| 脚本 | 用途 |
|---|---|
install-check.sh | 检查依赖是否安装 |
start-mcp.sh | 启动 MCP 服务 |
stop-mcp.sh | 停止 MCP 服务 |
status.sh | 检查登录状态 |
search.sh | 搜索内容 |
recommend.sh | 获取推荐列表 |
post-detail.sh | 获取帖子详情 |
comment.sh | 发表评论 |
user-profile.sh | 获取用户主页 |
publish.sh | 发布图文笔记 |
track-topic.sh | 热点追踪报告 |
references/
详细参考文档:
api-reference.md- MCP API 完整参考content-strategy.md- 内容策略指南troubleshooting.md- 常见问题解决
assets/
资源文件:
templates/- 内容模板images/- 示例图片
---
注意事项
1. 首次运行会下载 headless 浏览器(约 150MB) 2. 发布限制:标题≤20字符,正文≤1000字符,每日≤50条 3. 账号安全:避免多设备同时登录,Cookies 约 30 天过期 4. 合规使用:遵守小红书平台规则,不发布违规内容
---
声明
本 skill 基于 xiaohongshu-mcp 构建,仅提供 API 调用封装。请遵守小红书平台使用条款。
MIT License
Copyright (c) 2026 OpenClaw
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.小红书全流程运营工作流
<p align="center"> <b>基于 OpenClaw 的小红书运营自动化 Skill</b> </p>
<p align="center"> <a href="#功能特性">功能特性</a> • <a href="#快速开始">快速开始</a> • <a href="#使用方法">使用方法</a> • <a href="#目录结构">目录结构</a> </p>
---
功能特性
| 模块 | 功能 |
|---|---|
| 账号配置 | MCP 服务安装、登录获取 Cookies、服务启动 |
| 内容发布 | 图文/视频笔记发布、内容规范检查 |
| 热点追踪 | 关键词搜索、话题监控、报告生成 |
| 互动管理 | 评论获取、自动回复、粉丝互动 |
| 数据分析 | 表现监控、趋势分析、报警规则 |
| 记忆导出 | 收藏/点赞导出为 AI 可搜索知识库 |
快速开始
1. 安装依赖
# 下载 xiaohongshu-mcp
wget https://github.com/xpzouying/xiaohongshu-mcp/releases/latest/download/xiaohongshu-mcp-linux-amd64.tar.gz
wget https://github.com/xpzouying/xiaohongshu-mcp/releases/latest/download/xiaohongshu-login-linux-amd64.tar.gz
# 解压安装
mkdir -p ~/.local/bin
tar -xzf xiaohongshu-mcp-*.tar.gz -C ~/.local/bin/
tar -xzf xiaohongshu-login-*.tar.gz -C ~/.local/bin/
chmod +x ~/.local/bin/xiaohongshu-*2. 登录获取 Cookies
# 本地桌面环境
~/.local/bin/xiaohongshu-login
# Linux 服务器:从 Windows 复制 cookies
# Windows 运行 xiaohongshu-login-windows-amd64.exe
# Cookies 保存在 C:\Users\<用户名>\AppData\Local\Temp\cookies.json
# 复制到服务器:scp cookies.json user@server:~/.xiaohongshu/3. 启动服务
# 进入脚本目录
cd scripts/
# 检查依赖
./install-check.sh
# 启动 MCP 服务
./start-mcp.sh
# 检查状态
./status.sh4. 安装到 OpenClaw
# 链接到 workspace
ln -s /path/to/xiaohongshu-workflow ~/.openclaw/workspace/skills/xiaohongshu-workflow使用方法
搜索内容
./scripts/search.sh "OpenClaw"发布笔记
./scripts/mcp-call.sh publish_content '{
"title": "标题",
"content": "正文内容",
"images": ["/path/to/image1.jpg"],
"tags": ["标签1", "标签2"]
}'热点追踪报告
./scripts/track-topic.sh "DeepSeek" --limit 10 --output report.md获取帖子详情
./scripts/post-detail.sh <note_id> <xsec_token>目录结构
xiaohongshu-workflow/
├── SKILL.md # Skill 主文档
├── README.md # 说明文档
├── LICENSE # MIT 许可证
├── scripts/ # 可执行脚本
│ ├── install-check.sh # 依赖检查
│ ├── start-mcp.sh # 启动服务
│ ├── stop-mcp.sh # 停止服务
│ ├── status.sh # 状态检查
│ ├── login.sh # 登录
│ ├── search.sh # 搜索
│ ├── recommend.sh # 推荐
│ ├── post-detail.sh # 帖子详情
│ ├── comment.sh # 评论
│ ├── user-profile.sh # 用户主页
│ ├── track-topic.sh # 热点追踪
│ ├── track-topic.py # 追踪脚本
│ └── mcp-call.sh # 通用调用
└── references/ # 参考文档
├── api-reference.md # MCP API 参考
├── content-strategy.md # 内容策略指南
└── troubleshooting.md # 常见问题解决注意事项
- 发布限制:标题≤20字符,正文≤1000字符,每日≤50条
- 账号安全:避免多设备同时登录,Cookies 约 30 天过期
- 首次运行:会下载 headless 浏览器(约 150MB)
- 合规使用:遵守小红书平台规则,不发布违规内容
依赖
- xiaohongshu-mcp - 小红书 MCP 服务
- XHS-Downloader - 记忆导出(可选)
许可证
MIT License
致谢
MCP API 完整参考
基础配置
| 配置项 | 值 |
|---|---|
| MCP 服务地址 | http://localhost:18060/mcp |
| Cookies 路径 | ~/.xiaohongshu/cookies.json |
| 日志路径 | ~/.xiaohongshu/mcp.log |
---
工具列表
1. check_login_status
检查登录状态。
请求:
{
"tool": "check_login_status",
"params": {}
}响应:
{
"logged_in": true,
"user_id": "xxx",
"username": "用户名"
}---
2. search_feeds
搜索小红书内容。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| keyword | string | 是 | 搜索关键词 |
| limit | number | 否 | 返回数量,默认 20 |
请求:
{
"tool": "search_feeds",
"params": {
"keyword": "OpenClaw",
"limit": 10
}
}响应:
{
"feeds": [
{
"note_id": "xxx",
"title": "帖子标题",
"author": "作者名",
"liked_count": 100,
"xsec_token": "xxx"
}
]
}---
3. list_feeds
获取首页推荐列表。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| limit | number | 否 | 返回数量,默认 20 |
请求:
{
"tool": "list_feeds",
"params": {
"limit": 10
}
}---
4. get_feed_detail
获取帖子详情和评论。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| note_id | string | 是 | 帖子 ID |
| xsec_token | string | 是 | 安全 token |
请求:
{
"tool": "get_feed_detail",
"params": {
"note_id": "xxx",
"xsec_token": "xxx"
}
}响应:
{
"title": "帖子标题",
"content": "帖子正文",
"author": {
"user_id": "xxx",
"nickname": "作者昵称"
},
"liked_count": 100,
"collected_count": 50,
"comment_count": 20,
"shared_count": 10,
"comments": [
{
"id": "xxx",
"content": "评论内容",
"author": "评论者"
}
]
}---
5. post_comment_to_feed
发表评论。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| note_id | string | 是 | 帖子 ID |
| xsec_token | string | 是 | 安全 token |
| content | string | 是 | 评论内容 |
请求:
{
"tool": "post_comment_to_feed",
"params": {
"note_id": "xxx",
"xsec_token": "xxx",
"content": "写得很棒!"
}
}---
6. reply_comment_in_feed
回复评论。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| note_id | string | 是 | 帖子 ID |
| comment_id | string | 是 | 评论 ID |
| content | string | 是 | 回复内容 |
---
7. user_profile
获取用户主页。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| user_id | string | 是 | 用户 ID |
请求:
{
"tool": "user_profile",
"params": {
"user_id": "xxx"
}
}响应:
{
"user_id": "xxx",
"nickname": "用户昵称",
"desc": "个人简介",
"fans_count": 1000,
"follow_count": 100,
"liked_count": 5000,
"notes": [
{
"note_id": "xxx",
"title": "帖子标题"
}
]
}---
8. like_feed
点赞/取消点赞。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| note_id | string | 是 | 帖子 ID |
| xsec_token | string | 是 | 安全 token |
| like | boolean | 是 | true=点赞, false=取消 |
请求:
{
"tool": "like_feed",
"params": {
"note_id": "xxx",
"xsec_token": "xxx",
"like": true
}
}---
9. favorite_feed
收藏/取消收藏。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| note_id | string | 是 | 帖子 ID |
| xsec_token | string | 是 | 安全 token |
| favorite | boolean | 是 | true=收藏, false=取消 |
---
10. publish_content
发布图文笔记。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| title | string | 是 | 标题(≤20字符) |
| content | string | 是 | 正文(≤1000字符) |
| images | array | 是 | 图片路径列表(最多18张) |
| tags | array | 否 | 标签列表 |
请求:
{
"tool": "publish_content",
"params": {
"title": "标题",
"content": "正文内容",
"images": ["/path/to/image1.jpg", "/path/to/image2.jpg"],
"tags": ["标签1", "标签2"]
}
}响应:
{
"success": true,
"note_id": "xxx",
"url": "https://www.xiaohongshu.com/explore/xxx"
}---
11. publish_with_video
发布视频笔记。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| title | string | 是 | 标题(≤20字符) |
| content | string | 是 | 正文(≤1000字符) |
| video | string | 是 | 视频文件路径(≤15分钟) |
| cover | string | 否 | 封面图片路径 |
| tags | array | 否 | 标签列表 |
---
错误处理
常见错误码
| 错误码 | 说明 | 解决方法 |
|---|---|---|
| 401 | 未登录 | 重新获取 cookies |
| 429 | 请求频繁 | 降低请求频率 |
| 500 | 服务器错误 | 稍后重试 |
错误响应格式
{
"error": {
"code": 401,
"message": "未登录或登录已过期"
}
}---
调用示例
cURL
curl -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-d '{"tool": "check_login_status", "params": {}}'Python
import requests
def call_mcp(tool, params=None):
response = requests.post(
"http://localhost:18060/mcp",
json={"tool": tool, "params": params or {}}
)
return response.json()
# 使用示例
status = call_mcp("check_login_status")
feeds = call_mcp("search_feeds", {"keyword": "OpenClaw", "limit": 10})Bash (使用 jq)
#!/bin/bash
MCP_URL="http://localhost:18060/mcp"
mcp_call() {
local tool=$1
local params=$2
curl -s -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-d "{\"tool\": \"$tool\", \"params\": $params}" | jq .
}
# 使用示例
mcp_call "check_login_status" "{}"
mcp_call "search_feeds" '{"keyword": "OpenClaw", "limit": 10}'小红书内容策略指南
内容类型矩阵
| 类型 | 适合场景 | 发布频率 | 互动特点 |
|---|---|---|---|
| 教程类 | 产品使用、技巧分享 | 2-3篇/周 | 高收藏 |
| 案例类 | 成功故事、应用场景 | 1-2篇/周 | 高分享 |
| 热点类 | 行业动态、趋势分析 | 即时发布 | 高评论 |
| 互动类 | 问答、投票、征集 | 1篇/周 | 高评论 |
---
标题公式
高点击率标题模式
1. 数字+价值型
- "3分钟学会XXX"
- "5个技巧让你的XXX翻倍"
- "10个必备XXX工具"
2. 疑问+痛点型
- "为什么你的XXX总是XXX?"
- "还在为XXX烦恼吗?"
- "XXX真的有用吗?实测告诉你"
3. 情绪+共鸣型
- "终于找到了!XXX神器"
- "后悔没早点知道的XXX"
- "强烈推荐!这个XXX绝了"
4. 稀缺+紧迫型
- "限时分享!XXX"
- "内部资料!XXX"
- "最后机会!XXX"
标题避坑
- ❌ 过于平淡:"XXX介绍"
- ❌ 标题党:"震惊!XXX"
- ❌ 过长超过20字符
- ❌ 无关键词堆砌
---
首图设计原则
黄金法则
1. 信息密度适中 - 不要太满也不要太空 2. 对比度足够 - 确保文字可读 3. 品牌一致性 - 统一色调和风格 4. 重点突出 - 一个主视觉焦点
图片尺寸
| 类型 | 尺寸 | 比例 |
|---|---|---|
| 封面图 | 1080×1440 | 3:4 |
| 横图 | 1920×1080 | 16:9 |
| 方图 | 1080×1080 | 1:1 |
图片数量建议
- 推荐: 3-6 张
- 最少: 1 张(必须有封面)
- 最多: 18 张
---
正文结构模板
教程类模板
【标题】
👋 开头引入(1-2句话)
💡 核心内容
1. 第一步
- 详细说明
- 配图示例
2. 第二步
- 详细说明
- 配图示例
3. 第三步
- 详细说明
- 配图示例
📌 重点总结
💬 评论区见!有问题的都可以问~
#标签1 #标签2 #标签3案例类模板
【标题】
🎯 背景/问题
之前遇到了XXX问题,困扰了很久...
💡 解决方案
后来发现了XXX,试了一下效果惊艳!
📊 效果展示
(配图展示前后对比)
✨ 关键要点
1. 要点一
2. 要点二
3. 要点三
希望对大家有帮助!有问题评论区见~
#标签1 #标签2 #标签3热点类模板
【标题】
🔥 事件概述
XXX发生了,简单说一下...
📊 详细信息
- 要点一:XXX
- 要点二:XXX
- 要点三:XXX
💡 个人看法
我觉得XXX...
你怎么看?评论区聊聊~
#标签1 #标签2 #标签3---
标签策略
标签分类
1. 大流量标签(搜索量高,竞争激烈)
- #生活 #美食 #穿搭
2. 精准标签(搜索量中,竞争适中)
- #AI工具 #效率提升 #职场技巧
3. 长尾标签(搜索量低,竞争小)
- #OpenClaw教程 #AI数字伙伴
标签组合策略
推荐组合:1个大流量 + 2-3个精准 + 1个品牌/长尾
示例:
#AI(大流量)
#AI工具 #效率提升(精准)
#OpenClaw(品牌)---
发布时间优化
最佳发布时段
| 时段 | 时间 | 适合内容 |
|---|---|---|
| 早高峰 | 7:00-9:00 | 新闻、资讯 |
| 午休 | 12:00-13:00 | 轻松、娱乐 |
| 晚高峰 | 18:00-20:00 | 教程、干货 |
| 睡前 | 21:00-23:00 | 情感、故事 |
星期分布
| 星期 | 推荐内容 | 发布时间 |
|---|---|---|
| 周一 | 工作相关、效率 | 9:00 |
| 周二 | 教程、干货 | 18:00 |
| 周三 | 案例分享 | 18:00 |
| 周四 | 工具推荐 | 12:00 |
| 周五 | 热点追踪 | 12:00 |
| 周六 | 生活、休闲 | 10:00 |
| 周日 | 互动、问答 | 10:00 |
---
互动技巧
评论回复策略
1. 黄金时间 - 发布后1小时内回复 2. 引导互动 - 用问句结尾 3. 真诚回复 - 避免复制粘贴 4. 置顶精华 - 把有价值的评论置顶
回复模板
提问类:
👋 好问题!XXX...
具体可以看看这篇:[链接]
还有什么问题随时问~感谢类:
🙏 谢谢支持!
如果觉得有用的话可以收藏起来~
有问题评论区见!争议类:
理解你的观点~
每个人的使用场景不同,我说的是我的体验。
欢迎分享你的看法!---
数据分析指标
核心指标
| 指标 | 计算方式 | 健康值 |
|---|---|---|
| 点击率 | 点击/曝光 | >5% |
| 完读率 | 完读/点击 | >60% |
| 互动率 | (点赞+评论+收藏)/曝光 | >3% |
| 转化率 | 关注/曝光 | >0.5% |
优化方向
| 现象 | 问题 | 优化方向 |
|---|---|---|
| 点击率低 | 封面/标题不吸引 | 优化首图,调整标题 |
| 完读率低 | 内容不相关或质量差 | 提升内容质量 |
| 点赞多收藏少 | 娱乐性强,实用性弱 | 增加干货内容 |
| 收藏多点赞少 | 实用性强,共鸣感弱 | 增加情感表达 |
| 评论少 | 互动性弱 | 增加提问,引导讨论 |
---
违规避坑
禁止内容
- ❌ 涉黄涉政
- ❌ 虚假宣传
- ❌ 恶意引流
- ❌ 重复发布
- ❌ 抄袭搬运
- ❌ 敏感话题
敏感词替换
| 原词 | 替换词 |
|---|---|
| 微信 | V/绿色软件 |
| 添加 | ➕/关注 |
| 私信 | 评论区见 |
| 链接 | 首页有 |
---
账号成长路径
新手期(0-1000粉)
目标: 找到定位,建立风格
策略:
- 保持稳定更新频率
- 测试不同内容类型
- 积极互动回复评论
- 学习同类优秀账号
成长期(1000-1万粉)
目标: 稳定输出,建立人设
策略:
- 固定内容方向
- 打造个人IP
- 建立粉丝社群
- 尝试跨界合作
成熟期(1万粉以上)
目标: 商业变现,扩大影响
策略:
- 多平台分发
- 品牌合作
- 知识付费
- 社群运营
常见问题解决
安装问题
Q: xiaohongshu-mcp 下载失败
症状: wget 下载超时或连接失败
解决方法:
# 方法1: 使用代理
export https_proxy=http://127.0.0.1:7890
wget https://github.com/...
# 方法2: 使用镜像
wget https://ghproxy.com/https://github.com/...
# 方法3: 手动下载
# 从浏览器下载后上传到服务器Q: 解压后找不到可执行文件
症状: tar 解压后目录为空或找不到文件
解决方法:
# 查看压缩包内容
tar -tzf xiaohongshu-mcp-*.tar.gz
# 指定解压目录
mkdir -p ~/.local/bin
tar -xzf xiaohongshu-mcp-*.tar.gz -C ~/.local/bin/Q: 权限被拒绝
症状: Permission denied 错误
解决方法:
chmod +x ~/.local/bin/xiaohongshu-mcp
chmod +x ~/.local/bin/xiaohongshu-login---
登录问题
Q: 扫码登录后 cookies 保存在哪?
症状: 不知道 cookies 文件位置
解决方法:
# 默认位置(按优先级)
1. 环境变量 $XHS_COOKIES_SRC
2. ~/cookies.json
3. ~/.xiaohongshu/cookies.json
# Windows 登录后复制
cp /mnt/c/Users/<用户名>/AppData/Local/Temp/cookies.json ~/.xiaohongshu/Q: Cookies 过期怎么办?
症状: 登录已过期 或 未登录
解决方法: 1. 重新运行 xiaohongshu-login 扫码登录 2. 复制新的 cookies 到 ~/.xiaohongshu/cookies.json 3. 重启 MCP 服务
# 重启服务
pkill -f xiaohongshu-mcp
xiaohongshu-mcpQ: 无法打开浏览器扫码
症状: 服务器环境没有 GUI
解决方法: 1. 在本地电脑(有 GUI)运行 xiaohongshu-login 2. 复制 cookies 到服务器 3. 或使用 Windows 版本登录后复制
---
MCP 服务问题
Q: 服务启动失败
症状: xiaohongshu-mcp 命令无响应或报错
解决方法:
# 检查端口是否被占用
lsof -i:18060
# 检查 cookies 文件
ls -la ~/.xiaohongshu/cookies.json
# 查看日志
cat ~/.xiaohongshu/mcp.log
# 前台运行查看错误
xiaohongshu-mcp --headless=falseQ: 服务启动后无法连接
症状: curl 请求超时或拒绝连接
解决方法:
# 检查服务是否运行
ps aux | grep xiaohongshu-mcp
# 检查端口监听
netstat -tlnp | grep 18060
# 检查防火墙
sudo ufw status
# 重启服务
pkill -f xiaohongshu-mcp
xiaohongshu-mcpQ: 浏览器下载失败
症状: 首次启动下载 headless 浏览器失败
解决方法:
# 手动安装 Chromium
sudo apt-get install -y chromium-browser
# 或设置代理
export https_proxy=http://127.0.0.1:7890
xiaohongshu-mcp---
发布问题
Q: 发布失败,提示标题过长
症状: 标题超过20字符限制
解决方法:
# 缩短标题
title = "新标题"[:20]Q: 发布失败,提示正文过长
症状: 正文超过1000字符限制
解决方法:
# 分段或精简正文
content = content[:1000]Q: 图片上传失败
症状: 图片格式不支持 或 图片过大
解决方法:
# 支持的格式
- JPG/JPEG
- PNG
- WEBP
# 图片大小限制
- 单张 < 20MB
- 总数 < 18张
# 压缩图片
convert input.jpg -quality 85 output.jpgQ: 发布频率限制
症状: 发布过于频繁 或超过日限制
解决方法:
- 每日发布上限:50 条
- 发布间隔:建议 > 5 分钟
- 高峰期限流更严格
---
搜索和监控问题
Q: 搜索无结果
症状: 搜索返回空列表
解决方法:
# 检查登录状态
curl -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-d '{"tool": "check_login_status", "params": {}}'
# 尝试不同关键词
# 热门关键词更容易有结果Q: 获取帖子详情失败
症状: xsec_token 无效 或 note_id 不存在
解决方法:
# xsec_token 有时效性,需要重新搜索获取
# 先搜索获取最新的 token
curl -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-d '{"tool": "search_feeds", "params": {"keyword": "关键词"}}'Q: 监控脚本执行失败
症状: Permission denied 或 command not found
解决方法:
# 添加执行权限
chmod +x scripts/*.sh
# 检查 shebang
head -1 scripts/*.sh
# 应该是 #!/bin/bash
# 检查 Python 依赖
pip install requests---
评论和互动问题
Q: 评论发送失败
症状: 评论内容包含敏感词 或 评论频繁
解决方法:
- 检查评论内容是否包含敏感词
- 降低评论频率
- 避免重复发送相同内容
Q: 无法回复评论
症状: 评论不存在 或 权限不足
解决方法:
- 确保评论没有被删除
- 检查是否有回复权限
- 刷新帖子详情获取最新评论
---
性能问题
Q: 响应很慢
症状: API 响应时间 > 10 秒
解决方法:
# 检查服务器资源
top
free -h
df -h
# 检查网络延迟
ping www.xiaohongshu.com
# 减少并发请求
# 建议间隔 > 2 秒Q: 内存占用高
症状: MCP 服务占用大量内存
解决方法:
# 重启服务
pkill -f xiaohongshu-mcp
xiaohongshu-mcp
# 检查内存
ps aux | grep xiaohongshu-mcp---
调试技巧
启用详细日志
# 前台运行,查看详细输出
xiaohongshu-mcp --headless=false
# 查看日志文件
tail -f ~/.xiaohongshu/mcp.log测试 API 连接
# 基础连通测试
curl http://localhost:18060/mcp
# 登录状态测试
curl -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-d '{"tool": "check_login_status", "params": {}}'
# 搜索测试
curl -X POST http://localhost:18060/mcp \
-H "Content-Type: application/json" \
-d '{"tool": "search_feeds", "params": {"keyword": "test", "limit": 1}}'检查环境
# 检查 cookies
ls -la ~/.xiaohongshu/
cat ~/.xiaohongshu/cookies.json | python3 -m json.tool
# 检查进程
ps aux | grep xiaohongshu
# 检查端口
netstat -tlnp | grep 18060
lsof -i:18060#!/bin/bash
# 发表评论到小红书帖子
NOTE_ID="$1"
XSEC_TOKEN="$2"
CONTENT="$3"
if [ -z "$NOTE_ID" ] || [ -z "$XSEC_TOKEN" ] || [ -z "$CONTENT" ]; then
echo "用法: $0 <note_id> <xsec_token> <评论内容>"
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"$SCRIPT_DIR/mcp-call.sh" post_comment_to_feed "{\"note_id\": \"$NOTE_ID\", \"xsec_token\": \"$XSEC_TOKEN\", \"content\": \"$CONTENT\"}"
#!/bin/bash
# 检查小红书 MCP 依赖是否已安装
set -e
echo "检查小红书 MCP 依赖..."
echo ""
XHS_MCP="$HOME/.local/bin/xiaohongshu-mcp"
XHS_LOGIN="$HOME/.local/bin/xiaohongshu-login"
check_binary() {
local name="$1"
local path="$2"
if [ -f "$path" ]; then
echo "✅ $name: $path"
return 0
else
echo "❌ $name: 未找到"
return 1
fi
}
MISSING=0
check_binary "xiaohongshu-mcp" "$XHS_MCP" || MISSING=1
check_binary "xiaohongshu-login" "$XHS_LOGIN" || MISSING=1
echo ""
# 检查 jq(可选)
if command -v jq &> /dev/null; then
echo "✅ jq: $(which jq)"
else
echo "⚠️ jq: 未安装(可选,用于格式化 JSON 输出)"
fi
# 检查 Python3(track-topic.py 需要)
if command -v python3 &> /dev/null; then
echo "✅ python3: $(python3 --version)"
else
echo "⚠️ python3: 未安装(热点跟踪功能需要)"
fi
echo ""
if [ $MISSING -eq 1 ]; then
echo "=========================================="
echo "缺少必要依赖,请按以下步骤安装:"
echo ""
echo "1. 从 GitHub Releases 下载对应平台的二进制文件:"
echo " https://github.com/xpzouying/xiaohongshu-mcp/releases"
echo ""
echo "2. 解压并安装到 ~/.local/bin/:"
echo " mkdir -p ~/.local/bin"
echo " mv xiaohongshu-mcp-linux-amd64 ~/.local/bin/xiaohongshu-mcp"
echo " mv xiaohongshu-login-linux-amd64 ~/.local/bin/xiaohongshu-login"
echo " chmod +x ~/.local/bin/xiaohongshu-*"
echo ""
echo "3. 确保 ~/.local/bin 在 PATH 中(可选)"
echo "=========================================="
exit 1
else
echo "✅ 所有依赖已就绪"
fi
#!/bin/bash
# 启动小红书登录工具
XHS_LOGIN="$HOME/.local/bin/xiaohongshu-login"
echo "启动小红书登录工具..."
echo "注意:需要桌面环境或 X11 转发"
echo ""
"$XHS_LOGIN"
#!/bin/bash
# 通用 MCP 调用脚本(支持 Streamable HTTP + Session ID)
set -e
TOOL_NAME="$1"
TOOL_ARGS="$2"
MCP_URL="${MCP_URL:-http://localhost:18060/mcp}"
if [ -z "$TOOL_NAME" ]; then
echo "用法: $0 <tool_name> [json_args]"
echo ""
echo "可用工具:"
echo " check_login_status - 检查登录状态"
echo " search_feeds - 搜索内容 {\"keyword\": \"...\"}"
echo " list_feeds - 获取首页推荐"
echo " get_feed_detail - 获取帖子详情 {\"note_id\": \"...\", \"xsec_token\": \"...\"}"
echo " post_comment_to_feed - 发表评论 {\"note_id\": \"...\", \"xsec_token\": \"...\", \"content\": \"...\"}"
echo " user_profile - 获取用户主页 {\"user_id\": \"...\"}"
echo " like_feed - 点赞/取消 {\"note_id\": \"...\", \"xsec_token\": \"...\", \"like\": true}"
echo " favorite_feed - 收藏/取消 {\"note_id\": \"...\", \"xsec_token\": \"...\", \"favorite\": true}"
echo " get_login_qrcode - 获取登录二维码"
echo " publish_content - 发布图文"
echo " publish_with_video - 发布视频"
exit 1
fi
[ -z "$TOOL_ARGS" ] && TOOL_ARGS="{}"
# 1. Initialize 并获取 Session ID
INIT_RESPONSE=$(curl -s -i -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"openclaw","version":"1.0"}}}')
SESSION_ID=$(echo "$INIT_RESPONSE" | grep -i "Mcp-Session-Id" | awk '{print $2}' | tr -d '\r\n')
if [ -z "$SESSION_ID" ]; then
echo "错误: 无法获取 MCP Session ID"
echo "请确保 MCP 服务正在运行: ./start-mcp.sh"
exit 1
fi
# 2. Initialized notification
curl -s -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}' > /dev/null
# 3. Call tool
RESULT=$(curl -s --max-time 120 -X POST "$MCP_URL" \
-H "Content-Type: application/json" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"$TOOL_NAME\",\"arguments\":$TOOL_ARGS}}")
# 输出结果
if command -v jq &> /dev/null; then
echo "$RESULT" | jq .
else
echo "$RESULT"
fi
#!/bin/bash
# 获取小红书帖子详情
NOTE_ID="$1"
XSEC_TOKEN="$2"
if [ -z "$NOTE_ID" ] || [ -z "$XSEC_TOKEN" ]; then
echo "用法: $0 <note_id> <xsec_token>"
echo ""
echo "note_id 和 xsec_token 可从搜索或推荐结果中获取"
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"$SCRIPT_DIR/mcp-call.sh" get_feed_detail "{\"note_id\": \"$NOTE_ID\", \"xsec_token\": \"$XSEC_TOKEN\"}"
#!/bin/bash
# 获取小红书首页推荐列表
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"$SCRIPT_DIR/mcp-call.sh" list_feeds
#!/bin/bash
# 搜索小红书内容
KEYWORD="$1"
if [ -z "$KEYWORD" ]; then
echo "用法: $0 <关键词>"
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"$SCRIPT_DIR/mcp-call.sh" search_feeds "{\"keyword\": \"$KEYWORD\"}"
#!/bin/bash
# 启动小红书 MCP 服务
XHS_MCP="$HOME/.local/bin/xiaohongshu-mcp"
PID_FILE="$HOME/.xiaohongshu/mcp.pid"
LOG_FILE="$HOME/.xiaohongshu/mcp.log"
# Cookies 路径(可通过环境变量覆盖)
# XHS_COOKIES_SRC: 源 cookies 文件(用于远程服务器场景)
# 默认检查 ~/cookies.json 和 ~/.xiaohongshu/cookies.json
COOKIES_DST="/tmp/cookies.json"
mkdir -p "$HOME/.xiaohongshu"
# 同步 cookies(支持多个可能的来源)
sync_cookies() {
local src=""
# 优先使用环境变量指定的路径
if [ -n "$XHS_COOKIES_SRC" ] && [ -f "$XHS_COOKIES_SRC" ]; then
src="$XHS_COOKIES_SRC"
elif [ -f "$HOME/cookies.json" ]; then
src="$HOME/cookies.json"
elif [ -f "$HOME/.xiaohongshu/cookies.json" ]; then
src="$HOME/.xiaohongshu/cookies.json"
fi
if [ -n "$src" ]; then
if [ ! -f "$COOKIES_DST" ] || [ "$src" -nt "$COOKIES_DST" ]; then
cp "$src" "$COOKIES_DST"
echo "已同步 cookies: $src -> $COOKIES_DST"
fi
fi
}
sync_cookies
# 检查是否已在运行
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE")
if kill -0 "$PID" 2>/dev/null; then
echo "MCP 服务已在运行 (PID: $PID)"
echo "如需重启,请先运行 stop-mcp.sh"
exit 0
fi
fi
# 解析参数
HEADLESS="true"
for arg in "$@"; do
case $arg in
--headless=false)
HEADLESS="false"
;;
esac
done
# 启动服务
echo "启动小红书 MCP 服务..."
if [ "$HEADLESS" = "false" ]; then
nohup "$XHS_MCP" -headless=false > "$LOG_FILE" 2>&1 &
else
nohup "$XHS_MCP" > "$LOG_FILE" 2>&1 &
fi
echo $! > "$PID_FILE"
sleep 2
# 验证启动
if kill -0 $(cat "$PID_FILE") 2>/dev/null; then
echo "✓ MCP 服务已启动 (PID: $(cat $PID_FILE))"
echo " 端点: http://localhost:18060/mcp"
echo " 日志: $LOG_FILE"
else
echo "✗ 启动失败,查看日志: $LOG_FILE"
cat "$LOG_FILE"
exit 1
fi
#!/bin/bash
# 检查小红书登录状态
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"$SCRIPT_DIR/mcp-call.sh" check_login_status
#!/bin/bash
# 停止小红书 MCP 服务
PID_FILE="$HOME/.xiaohongshu/mcp.pid"
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE")
if kill -0 "$PID" 2>/dev/null; then
kill "$PID"
rm -f "$PID_FILE"
echo "✓ MCP 服务已停止"
else
echo "进程不存在,清理 PID 文件"
rm -f "$PID_FILE"
fi
else
echo "MCP 服务未运行"
fi
#!/usr/bin/env python3
"""
小红书热点跟踪工具
用法:
python track-topic.py <话题> [--limit N] [--feishu] [--output FILE]
示例:
python track-topic.py "DeepSeek" --limit 5 --feishu
python track-topic.py "春节旅游" --limit 10 --output report.md
"""
import argparse
import json
import subprocess
import sys
import os
from datetime import datetime
from pathlib import Path
# 获取脚本目录
SCRIPT_DIR = Path(__file__).parent.resolve()
XHS_SCRIPTS = SCRIPT_DIR # 现在就在 xiaohongshu/scripts 目录下
# 飞书 skill 路径(支持多种可能的位置)
def find_feishu_scripts() -> Path:
"""查找 feishu-docs skill 的 scripts 目录"""
possible_paths = [
SCRIPT_DIR.parent.parent / "feishu-docs" / "scripts", # 同级 skill
Path.home() / ".openclaw" / "workspace" / "skills" / "feishu-docs" / "scripts",
Path.home() / ".claude" / "skills" / "feishu-docs" / "scripts",
]
for p in possible_paths:
if p.exists():
return p
return possible_paths[0] # 返回默认路径(可能不存在)
FEISHU_SCRIPTS = find_feishu_scripts()
def call_xhs_mcp(tool: str, args: dict) -> dict:
"""调用小红书 MCP 工具"""
mcp_call = XHS_SCRIPTS / "mcp-call.sh"
if not mcp_call.exists():
print(f"❌ 找不到 xiaohongshu skill: {mcp_call}", file=sys.stderr)
sys.exit(1)
result = subprocess.run(
[str(mcp_call), tool, json.dumps(args)],
capture_output=True, text=True, timeout=120
)
if result.returncode != 0:
print(f"❌ MCP 调用失败: {result.stderr}", file=sys.stderr)
return {}
try:
response = json.loads(result.stdout)
if "result" in response and "content" in response["result"]:
text = response["result"]["content"][0].get("text", "{}")
return json.loads(text) if text else {}
elif "error" in response:
print(f"⚠️ MCP 错误: {response['error'].get('message', 'Unknown')}", file=sys.stderr)
return {}
return response
except json.JSONDecodeError:
return {}
def search_feeds(keyword: str) -> list:
"""搜索小红书内容"""
print(f"🔍 搜索: {keyword}")
result = call_xhs_mcp("search_feeds", {"keyword": keyword})
feeds = result.get("feeds", [])
# 过滤掉 hot_query 类型
return [f for f in feeds if f.get("modelType") == "note"]
def get_feed_detail(feed_id: str, xsec_token: str, load_comments: bool = True) -> dict:
"""获取帖子详情"""
args = {
"feed_id": feed_id,
"xsec_token": xsec_token,
"load_all_comments": load_comments
}
result = call_xhs_mcp("get_feed_detail", args)
return result.get("data", {})
def format_timestamp(ts: int) -> str:
"""格式化时间戳"""
if not ts:
return "未知"
try:
dt = datetime.fromtimestamp(ts / 1000)
return dt.strftime("%Y-%m-%d %H:%M")
except:
return "未知"
def get_comments_list(post: dict) -> list:
"""安全地获取评论列表"""
comments = post.get("comments", {})
if isinstance(comments, dict):
return comments.get("list", [])
elif isinstance(comments, list):
return comments
return []
def generate_report(keyword: str, posts: list) -> str:
"""生成 Markdown 报告"""
now = datetime.now().strftime("%Y-%m-%d %H:%M")
report = f"""# 🔥 小红书热点跟踪报告
**话题:** {keyword}
**生成时间:** {now}
**收录帖子:** {len(posts)} 篇
---
## 📊 概览
"""
# 统计信息
total_likes = sum(int(p.get("note", {}).get("interactInfo", {}).get("likedCount", 0) or 0) for p in posts)
total_comments = sum(len(get_comments_list(p)) for p in posts)
report += f"""| 指标 | 数值 |
|------|------|
| 总帖子数 | {len(posts)} |
| 总点赞数 | {total_likes:,} |
| 总评论数 | {total_comments} |
---
## 📝 热帖详情
"""
for i, post in enumerate(posts, 1):
note = post.get("note", {})
comments = get_comments_list(post)
title = note.get("title", "无标题")
desc = note.get("desc", "")
user = note.get("user", {}).get("nickname", "匿名")
time_str = format_timestamp(note.get("time"))
interact = note.get("interactInfo", {})
likes = interact.get("likedCount", "0")
collected = interact.get("collectedCount", "0")
report += f"""### {i}. {title}
**作者:** {user}
**时间:** {time_str}
**互动:** ❤️ {likes} 赞 · ⭐ {collected} 收藏
**正文:**
> {desc[:500]}{"..." if len(desc) > 500 else ""}
"""
if comments:
report += f"""**热门评论 ({len(comments)} 条):**
"""
for j, comment in enumerate(list(comments)[:5], 1):
c_user = comment.get("userInfo", {}).get("nickname", "匿名")
c_content = comment.get("content", "")
c_likes = comment.get("likeCount", 0)
report += f"- **{c_user}** ({c_likes}赞): {c_content[:100]}\n"
if len(comments) > 5:
report += f"- *... 还有 {len(comments) - 5} 条评论*\n"
report += "\n---\n\n"
# 评论区热点总结
report += """## 💬 评论区热点关键词
"""
# 简单的关键词提取(统计高频词)
all_comments = []
for post in posts:
for c in get_comments_list(post):
all_comments.append(c.get("content", ""))
if all_comments:
report += f"共 {len(all_comments)} 条评论,主要讨论方向:\n\n"
# 这里可以做更复杂的 NLP 分析,暂时简化
report += "- 用户对该话题的关注度较高\n"
report += "- 评论区互动活跃\n"
else:
report += "暂无足够评论数据进行分析\n"
report += """
---
## 📈 趋势分析
基于以上热帖和评论数据,该话题在小红书上呈现以下特点:
1. **热度指数**: """ + ("🔥🔥🔥 高" if total_likes > 1000 else "🔥🔥 中" if total_likes > 100 else "🔥 低") + f"""
2. **互动活跃度**: """ + ("活跃" if total_comments > 50 else "一般" if total_comments > 10 else "较低") + """
3. **内容类型**: 以图文笔记为主
---
*报告由 OpenClaw 小红书热点跟踪工具自动生成*
"""
return report
def export_to_feishu(title: str, content: str) -> str:
"""导出到飞书文档"""
import_script = FEISHU_SCRIPTS / "doc-import.sh"
if not import_script.exists():
print(f"❌ 找不到 feishu-docs skill: {import_script}", file=sys.stderr)
return ""
print("📤 导出到飞书文档...")
# 写入临时文件
tmp_file = Path("/tmp/xhs_report.md")
tmp_file.write_text(content, encoding="utf-8")
result = subprocess.run(
[str(import_script), title, "--file", str(tmp_file)],
capture_output=True, text=True, timeout=60
)
if result.returncode != 0:
print(f"⚠️ 飞书导出失败: {result.stderr}", file=sys.stderr)
return ""
# 解析返回的文档链接
output = result.stdout
print(output)
return output
def main():
parser = argparse.ArgumentParser(description="小红书热点跟踪工具")
parser.add_argument("keyword", help="要跟踪的话题/关键词")
parser.add_argument("--limit", "-n", type=int, default=10, help="获取帖子数量 (默认 10)")
parser.add_argument("--feishu", "-f", action="store_true", help="导出到飞书文档")
parser.add_argument("--output", "-o", help="输出 Markdown 文件路径")
parser.add_argument("--no-comments", action="store_true", help="不获取评论")
args = parser.parse_args()
# 1. 搜索帖子
feeds = search_feeds(args.keyword)
if not feeds:
print("❌ 未找到相关帖子")
sys.exit(1)
print(f"✅ 找到 {len(feeds)} 条帖子")
# 2. 获取详情
posts = []
for i, feed in enumerate(feeds[:args.limit]):
feed_id = feed.get("id")
xsec_token = feed.get("xsecToken")
title = feed.get("noteCard", {}).get("displayTitle", "")
print(f"📖 [{i+1}/{min(len(feeds), args.limit)}] 获取: {title[:30]}...")
detail = get_feed_detail(feed_id, xsec_token, not args.no_comments)
if detail:
posts.append(detail)
if not posts:
print("❌ 未能获取帖子详情")
sys.exit(1)
print(f"✅ 成功获取 {len(posts)} 篇帖子详情")
# 3. 生成报告
print("📝 生成报告...")
report = generate_report(args.keyword, posts)
# 4. 输出
if args.output:
output_path = Path(args.output)
output_path.write_text(report, encoding="utf-8")
print(f"✅ 报告已保存: {output_path}")
if args.feishu:
doc_title = f"小红书热点跟踪: {args.keyword} ({datetime.now().strftime('%m-%d')})"
export_to_feishu(doc_title, report)
if not args.output and not args.feishu:
# 默认输出到 stdout
print("\n" + "="*60 + "\n")
print(report)
return report
if __name__ == "__main__":
main()
#!/bin/bash
# 小红书热点跟踪工具
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
python3 "$SCRIPT_DIR/track-topic.py" "$@"
#!/bin/bash
# 获取小红书用户主页
USER_ID="$1"
if [ -z "$USER_ID" ]; then
echo "用法: $0 <user_id>"
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"$SCRIPT_DIR/mcp-call.sh" user_profile "{\"user_id\": \"$USER_ID\"}"
GitHub 上传指南
Skill 已创建完成!
位置: /home/shengz/.openclaw/workspace/skills/xiaohongshu-workflow/
已打包文件: /home/shengz/.openclaw/workspace/xiaohongshu-workflow.skill
---
上传到 GitHub 的步骤
方式一:手动上传(推荐)
1. 创建 GitHub 仓库
- 访问 https://github.com/new
- 仓库名:
xiaohongshu-workflow - 描述: 小红书全流程运营工作流 OpenClaw Skill
- 设为 Public
- 不要勾选 "Add a README file"
- 点击 "Create repository"
2. 在服务器上配置 Git
# 如果没有 SSH key,创建一个
ssh-keygen -t ed25519 -C "your-email@example.com"
# 查看公钥
cat ~/.ssh/id_ed25519.pub
# 将公钥添加到 GitHub: Settings -> SSH and GPG keys -> New SSH key3. 推送代码
cd /home/shengz/.openclaw/workspace/skills/xiaohongshu-workflow
# 添加远程仓库(替换为你的用户名)
git remote add origin git@github.com:YOUR_USERNAME/xiaohongshu-workflow.git
# 重命名分支为 main
git branch -M main
# 推送
git push -u origin main方式二:上传 .skill 文件
1. 访问 https://github.com/new 创建新仓库 2. 将 /home/shengz/.openclaw/workspace/xiaohongshu-workflow.skill 文件上传到仓库 3. 这个 .skill 文件可以直接被 OpenClaw 安装
方式三:使用 GitHub CLI(需要安装)
# 安装 GitHub CLI
sudo apt install gh
# 登录
gh auth login
# 创建仓库并推送
cd /home/shengz/.openclaw/workspace/skills/xiaohongshu-workflow
gh repo create xiaohongshu-workflow --public --source=. --push---
Skill 内容概览
xiaohongshu-workflow/
├── SKILL.md # 主文档 (415 行)
├── README.md # 说明文档
├── LICENSE # MIT 许可证
├── .gitignore
├── scripts/ # 可执行脚本 (13 个)
│ ├── install-check.sh
│ ├── start-mcp.sh
│ ├── stop-mcp.sh
│ ├── status.sh
│ ├── login.sh
│ ├── search.sh
│ ├── recommend.sh
│ ├── post-detail.sh
│ ├── comment.sh
│ ├── user-profile.sh
│ ├── track-topic.sh
│ ├── track-topic.py
│ └── mcp-call.sh
└── references/ # 参考文档 (3 个)
├── api-reference.md # MCP API 完整参考
├── content-strategy.md # 内容策略指南
└── troubleshooting.md # 常见问题解决总计: 20 个文件, 2260 行代码
---
功能特性
| 模块 | 功能 |
|---|---|
| 账号配置 | MCP 服务安装、登录获取 Cookies、服务启动 |
| 内容发布 | 图文/视频笔记发布、内容规范检查 |
| 热点追踪 | 关键词搜索、话题监控、报告生成 |
| 互动管理 | 评论获取、自动回复、粉丝互动 |
| 数据分析 | 表现监控、趋势分析、报警规则 |
| 记忆导出 | 收藏/点赞导出为 AI 可搜索知识库 |