redbook-cli 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redbook_cli-0.2.0/.github/workflows/publish.yml +24 -0
- redbook_cli-0.2.0/.gitignore +26 -0
- redbook_cli-0.2.0/LICENSE +21 -0
- redbook_cli-0.2.0/PKG-INFO +403 -0
- redbook_cli-0.2.0/README.md +379 -0
- redbook_cli-0.2.0/README.zh-CN.md +137 -0
- redbook_cli-0.2.0/SCHEMA.md +26 -0
- redbook_cli-0.2.0/SKILL.md +221 -0
- redbook_cli-0.2.0/activate.sh +12 -0
- redbook_cli-0.2.0/config/accounts.json.example +15 -0
- redbook_cli-0.2.0/demo.gif +0 -0
- redbook_cli-0.2.0/docs/claude-code-integration.md +113 -0
- redbook_cli-0.2.0/docs/cli-guide.md +273 -0
- redbook_cli-0.2.0/manifest.json +11 -0
- redbook_cli-0.2.0/mcp/start.sh +16 -0
- redbook_cli-0.2.0/mcp/xiaohongshu-login-darwin-arm64 +0 -0
- redbook_cli-0.2.0/mcp/xiaohongshu-mcp-darwin-arm64 +0 -0
- redbook_cli-0.2.0/pyproject.toml +53 -0
- redbook_cli-0.2.0/requirements.txt +2 -0
- redbook_cli-0.2.0/scripts/account_manager.py +310 -0
- redbook_cli-0.2.0/scripts/cdp_publish.py +2691 -0
- redbook_cli-0.2.0/scripts/chrome_launcher.py +335 -0
- redbook_cli-0.2.0/scripts/feed_explorer.py +688 -0
- redbook_cli-0.2.0/scripts/image_downloader.py +201 -0
- redbook_cli-0.2.0/scripts/publish_pipeline.py +568 -0
- redbook_cli-0.2.0/scripts/run_lock.py +124 -0
- redbook_cli-0.2.0/setup.bat +82 -0
- redbook_cli-0.2.0/setup.sh +134 -0
- redbook_cli-0.2.0/src/xhs_cli/__init__.py +2 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/__init__.py +0 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/account.py +93 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/analytics.py +105 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/auth.py +145 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/config_cmd.py +66 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/init.py +232 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/interact.py +145 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/profile.py +86 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/publish.py +171 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/search.py +209 -0
- redbook_cli-0.2.0/src/xhs_cli/commands/server.py +104 -0
- redbook_cli-0.2.0/src/xhs_cli/engines/__init__.py +0 -0
- redbook_cli-0.2.0/src/xhs_cli/engines/cdp_client.py +280 -0
- redbook_cli-0.2.0/src/xhs_cli/engines/mcp_client.py +422 -0
- redbook_cli-0.2.0/src/xhs_cli/main.py +132 -0
- redbook_cli-0.2.0/src/xhs_cli/utils/__init__.py +0 -0
- redbook_cli-0.2.0/src/xhs_cli/utils/config.py +96 -0
- redbook_cli-0.2.0/src/xhs_cli/utils/envelope.py +49 -0
- redbook_cli-0.2.0/src/xhs_cli/utils/export.py +68 -0
- redbook_cli-0.2.0/src/xhs_cli/utils/index_cache.py +82 -0
- redbook_cli-0.2.0/src/xhs_cli/utils/output.py +296 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment: pypi
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- name: Install build tools
|
|
20
|
+
run: pip install build
|
|
21
|
+
- name: Build package
|
|
22
|
+
run: python -m build
|
|
23
|
+
- name: Publish to PyPI
|
|
24
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Runtime & sensitive
|
|
2
|
+
mcp/cookies.json
|
|
3
|
+
mcp/cookies.json.bak
|
|
4
|
+
mcp/mcp.log
|
|
5
|
+
tmp/
|
|
6
|
+
config/accounts.json
|
|
7
|
+
login_status_cache.json
|
|
8
|
+
|
|
9
|
+
# Python
|
|
10
|
+
__pycache__/
|
|
11
|
+
*.pyc
|
|
12
|
+
*.egg-info/
|
|
13
|
+
.venv/
|
|
14
|
+
dist/
|
|
15
|
+
build/
|
|
16
|
+
|
|
17
|
+
# Config
|
|
18
|
+
~/.xhs/
|
|
19
|
+
|
|
20
|
+
# OS
|
|
21
|
+
.DS_Store
|
|
22
|
+
Thumbs.db
|
|
23
|
+
|
|
24
|
+
# IDE
|
|
25
|
+
.vscode/
|
|
26
|
+
.idea/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 angiin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: redbook-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: 小红书命令行工具 — 搜索、发布、互动、数据分析、短索引导航
|
|
5
|
+
Project-URL: Homepage, https://github.com/Youhai020616/xiaohongshu
|
|
6
|
+
Project-URL: Repository, https://github.com/Youhai020616/xiaohongshu
|
|
7
|
+
Author-email: Youhai <youhai020616@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: cli,redbook,xhs,xiaohongshu,小红书
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Utilities
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Requires-Dist: browser-cookie3>=0.19
|
|
18
|
+
Requires-Dist: click>=8.0
|
|
19
|
+
Requires-Dist: pyyaml>=6.0
|
|
20
|
+
Requires-Dist: requests>=2.28.0
|
|
21
|
+
Requires-Dist: rich>=13.0
|
|
22
|
+
Requires-Dist: websockets>=12.0
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<h1 align="center">📕 xiaohongshu</h1>
|
|
27
|
+
<p align="center">AI-powered Xiaohongshu (小红书/RED) automation — publish, search, engage, and analyze.</p>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="#cli-quick-start">CLI Quick Start</a> •
|
|
32
|
+
<a href="#features">Features</a> •
|
|
33
|
+
<a href="#quick-start">Quick Start</a> •
|
|
34
|
+
<a href="#mcp-tools">MCP Tools</a> •
|
|
35
|
+
<a href="#cdp-scripts">CDP Scripts</a> •
|
|
36
|
+
<a href="#openclaw-integration">OpenClaw</a> •
|
|
37
|
+
<a href="#claude-code-integration">Claude Code</a> •
|
|
38
|
+
<a href="./LICENSE">License</a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<img src="./demo.gif" alt="xiaohongshu demo" width="800">
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
## CLI Quick Start
|
|
48
|
+
|
|
49
|
+
The fastest way to get started — **3 commands** from zero to posting:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# 1. Clone
|
|
53
|
+
git clone https://github.com/Youhai020616/xiaohongshu.git
|
|
54
|
+
cd xiaohongshu
|
|
55
|
+
|
|
56
|
+
# 2. One-click install (auto: Python check → venv → pip install → MCP binary)
|
|
57
|
+
bash setup.sh
|
|
58
|
+
|
|
59
|
+
# 3. Initialize (auto: proxy config → start MCP → QR login)
|
|
60
|
+
source activate.sh && xhs init
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then just use:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
xhs search "AI创业" # Search
|
|
67
|
+
xhs publish -t "Hello" -c "My first post" -i photo.jpg # Publish
|
|
68
|
+
xhs like FEED_ID -t TOKEN # Like
|
|
69
|
+
xhs analytics # Dashboard
|
|
70
|
+
xhs --help # All commands
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> 📖 Full CLI guide: [docs/cli-guide.md](docs/cli-guide.md)
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## What is this?
|
|
78
|
+
|
|
79
|
+
A complete toolkit for automating Xiaohongshu (小红书/RED Note) operations through two complementary engines:
|
|
80
|
+
|
|
81
|
+
| Engine | Technology | Use Cases | Startup |
|
|
82
|
+
|--------|-----------|-----------|---------|
|
|
83
|
+
| **MCP Server** | Go binary, JSON-RPC | Publish, search, comment, like, follow | Always-on daemon |
|
|
84
|
+
| **CDP Scripts** | Python, Chrome DevTools | Analytics dashboard, notifications, advanced search | On-demand |
|
|
85
|
+
|
|
86
|
+
Built as an [OpenClaw](https://github.com/openclaw/openclaw) Skill, but works standalone or with any MCP-compatible client (Claude Code, Cursor, etc.).
|
|
87
|
+
|
|
88
|
+
## Features
|
|
89
|
+
|
|
90
|
+
- 📝 **Publish** — Image posts and video posts with tags, scheduling, and visibility control
|
|
91
|
+
- 🔍 **Search** — Keyword search with filters (sort, note type, suggested keywords)
|
|
92
|
+
- 💬 **Engage** — Comment, reply, like, favorite on any post
|
|
93
|
+
- 👤 **Profile** — Fetch any user's profile and posts
|
|
94
|
+
- 📊 **Analytics** — Creator dashboard data export (CSV), content performance metrics
|
|
95
|
+
- 🔔 **Notifications** — Fetch mentions and interaction notifications
|
|
96
|
+
- 👥 **Multi-Account** — Isolated Chrome profiles per account
|
|
97
|
+
- 🔐 **QR Code Login** — Scan-to-login, persistent cookie storage
|
|
98
|
+
|
|
99
|
+
## Quick Start
|
|
100
|
+
|
|
101
|
+
### Prerequisites
|
|
102
|
+
|
|
103
|
+
- macOS (Apple Silicon) — MCP binary is pre-built for `darwin-arm64`
|
|
104
|
+
- Python 3.9+ (for CDP scripts)
|
|
105
|
+
- Google Chrome (for CDP scripts and QR login)
|
|
106
|
+
- A proxy/VPN if outside China (MCP requires `-rod` proxy flag)
|
|
107
|
+
|
|
108
|
+
### 1. Clone
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
git clone https://github.com/Youhai020616/xiaohongshu.git
|
|
112
|
+
cd xiaohongshu
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 2. Start MCP Server
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
cd mcp
|
|
119
|
+
chmod +x xiaohongshu-mcp-darwin-arm64
|
|
120
|
+
|
|
121
|
+
# Without proxy (inside China)
|
|
122
|
+
./xiaohongshu-mcp-darwin-arm64 -port :18060
|
|
123
|
+
|
|
124
|
+
# With proxy (outside China)
|
|
125
|
+
./xiaohongshu-mcp-darwin-arm64 -port :18060 -rod "proxy=http://127.0.0.1:7897"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 3. Login
|
|
129
|
+
|
|
130
|
+
On first run, get a QR code to scan with your Xiaohongshu app:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
curl -s -X POST http://127.0.0.1:18060/mcp \
|
|
134
|
+
-H "Content-Type: application/json" \
|
|
135
|
+
-H "Accept: application/json, text/event-stream" \
|
|
136
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"cli","version":"1.0"}}}'
|
|
137
|
+
# Save the Mcp-Session-Id from response headers
|
|
138
|
+
|
|
139
|
+
curl -s -X POST http://127.0.0.1:18060/mcp \
|
|
140
|
+
-H "Content-Type: application/json" \
|
|
141
|
+
-H "Accept: application/json, text/event-stream" \
|
|
142
|
+
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
|
|
143
|
+
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
|
|
144
|
+
|
|
145
|
+
curl -s -X POST http://127.0.0.1:18060/mcp \
|
|
146
|
+
-H "Content-Type: application/json" \
|
|
147
|
+
-H "Accept: application/json, text/event-stream" \
|
|
148
|
+
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
|
|
149
|
+
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_login_qrcode","arguments":{}}}'
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Or use the login helper binary:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
cd mcp
|
|
156
|
+
./xiaohongshu-login-darwin-arm64
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 4. Publish Your First Post
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
curl -s -X POST http://127.0.0.1:18060/mcp \
|
|
163
|
+
-H "Content-Type: application/json" \
|
|
164
|
+
-H "Accept: application/json, text/event-stream" \
|
|
165
|
+
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
|
|
166
|
+
-d '{
|
|
167
|
+
"jsonrpc":"2.0","id":3,
|
|
168
|
+
"method":"tools/call",
|
|
169
|
+
"params":{
|
|
170
|
+
"name":"publish_content",
|
|
171
|
+
"arguments":{
|
|
172
|
+
"title":"Hello from API 🚀",
|
|
173
|
+
"content":"My first automated post on Xiaohongshu!",
|
|
174
|
+
"images":["/path/to/image.jpg"],
|
|
175
|
+
"tags":["测试","自动化"]
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}'
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## MCP Tools
|
|
182
|
+
|
|
183
|
+
The MCP server exposes these tools via the [Model Context Protocol](https://modelcontextprotocol.io/):
|
|
184
|
+
|
|
185
|
+
| Tool | Description | Key Parameters |
|
|
186
|
+
|------|-------------|----------------|
|
|
187
|
+
| `check_login_status` | Check if logged in | — |
|
|
188
|
+
| `get_login_qrcode` | Get QR code for login (base64) | — |
|
|
189
|
+
| `delete_cookies` | Reset login state | — |
|
|
190
|
+
| `publish_content` | Publish image post | `title`, `content`, `images`, `tags?`, `visibility?`, `is_original?`, `schedule_at?` |
|
|
191
|
+
| `publish_with_video` | Publish video post | `title`, `content`, `video` (local path), `tags?`, `visibility?`, `schedule_at?` |
|
|
192
|
+
| `search_feeds` | Search posts by keyword | `keyword`, `filters?` |
|
|
193
|
+
| `get_feed_detail` | Get post details + comments | `feed_id`, `xsec_token`, `load_all_comments?` |
|
|
194
|
+
| `post_comment_to_feed` | Comment on a post | `feed_id`, `xsec_token`, `content` |
|
|
195
|
+
| `reply_comment_in_feed` | Reply to a comment | `feed_id`, `xsec_token`, `comment_id`, `user_id`, `content` |
|
|
196
|
+
| `like_feed` | Like / unlike a post | `feed_id`, `xsec_token`, `unlike?` |
|
|
197
|
+
| `favorite_feed` | Favorite / unfavorite a post | `feed_id`, `xsec_token`, `unfavorite?` |
|
|
198
|
+
| `list_feeds` | Get homepage feed | — |
|
|
199
|
+
| `user_profile` | Get user profile + posts | `user_id`, `xsec_token` |
|
|
200
|
+
| `get_self_info` | Get own account info | — |
|
|
201
|
+
|
|
202
|
+
### MCP Session Protocol
|
|
203
|
+
|
|
204
|
+
The MCP server uses [Streamable HTTP](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) transport. Every request must include:
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
Content-Type: application/json
|
|
208
|
+
Accept: application/json, text/event-stream
|
|
209
|
+
Mcp-Session-Id: <from initialize response header>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Session lifecycle: `initialize` → `notifications/initialized` → `tools/call` (repeat)
|
|
213
|
+
|
|
214
|
+
### Parameters Reference
|
|
215
|
+
|
|
216
|
+
**`publish_content`**
|
|
217
|
+
- `title` (string, required) — Max 20 Chinese characters
|
|
218
|
+
- `content` (string, required) — Post body, max 1000 characters. Do NOT include hashtags here
|
|
219
|
+
- `images` (string[], required) — Local file paths or HTTP URLs (at least 1)
|
|
220
|
+
- `tags` (string[], optional) — Hashtags, e.g. `["旅行", "美食"]`
|
|
221
|
+
- `visibility` (string, optional) — `公开可见` (default) / `仅自己可见` / `仅互关好友可见`
|
|
222
|
+
- `is_original` (bool, optional) — Declare as original content
|
|
223
|
+
- `schedule_at` (string, optional) — ISO 8601 datetime, e.g. `2026-03-15T10:30:00+08:00`
|
|
224
|
+
|
|
225
|
+
**`publish_with_video`**
|
|
226
|
+
- `video` (string, required) — Local absolute path to video file only
|
|
227
|
+
|
|
228
|
+
## CDP Scripts
|
|
229
|
+
|
|
230
|
+
For features the MCP server doesn't support (analytics, notifications, suggested keywords), use the Python CDP scripts:
|
|
231
|
+
|
|
232
|
+
### Setup
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
pip install -r requirements.txt
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Chrome Launcher
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Start Chrome with isolated profile
|
|
242
|
+
python scripts/chrome_launcher.py
|
|
243
|
+
|
|
244
|
+
# Headless mode
|
|
245
|
+
python scripts/chrome_launcher.py --headless
|
|
246
|
+
|
|
247
|
+
# Stop Chrome
|
|
248
|
+
python scripts/chrome_launcher.py --kill
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Available Commands
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Login (scan QR code)
|
|
255
|
+
python scripts/cdp_publish.py login
|
|
256
|
+
|
|
257
|
+
# Creator dashboard data → CSV
|
|
258
|
+
python scripts/cdp_publish.py content-data --csv-file output.csv
|
|
259
|
+
|
|
260
|
+
# Notification mentions
|
|
261
|
+
python scripts/cdp_publish.py get-notification-mentions
|
|
262
|
+
|
|
263
|
+
# Search with filters
|
|
264
|
+
python scripts/cdp_publish.py search-feeds --keyword "AI创业" --sort-by 最新 --note-type 图文
|
|
265
|
+
|
|
266
|
+
# Post detail
|
|
267
|
+
python scripts/cdp_publish.py get-feed-detail --feed-id FEED_ID --xsec-token TOKEN
|
|
268
|
+
|
|
269
|
+
# Comment
|
|
270
|
+
python scripts/cdp_publish.py post-comment-to-feed --feed-id FEED_ID --xsec-token TOKEN --content "Great post!"
|
|
271
|
+
|
|
272
|
+
# Publish via CDP (alternative to MCP)
|
|
273
|
+
python scripts/publish_pipeline.py --headless \
|
|
274
|
+
--title-file title.txt --content-file content.txt \
|
|
275
|
+
--image-urls "https://example.com/img.jpg"
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Multi-Account
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
python scripts/cdp_publish.py add-account work --alias "Work Account"
|
|
282
|
+
python scripts/cdp_publish.py --account work login
|
|
283
|
+
python scripts/cdp_publish.py --account work content-data
|
|
284
|
+
python scripts/cdp_publish.py list-accounts
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## OpenClaw Integration
|
|
288
|
+
|
|
289
|
+
Install as an OpenClaw skill:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
# Copy to skills directory
|
|
293
|
+
cp -r xiaohongshu ~/.openclaw/skills/xiaohongshu
|
|
294
|
+
|
|
295
|
+
# Start MCP server
|
|
296
|
+
cd ~/.openclaw/skills/xiaohongshu/mcp
|
|
297
|
+
./start.sh
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
The `SKILL.md` file provides full instructions for OpenClaw's AI agent to use the tools automatically.
|
|
301
|
+
|
|
302
|
+
## Claude Code Integration
|
|
303
|
+
|
|
304
|
+
See [docs/claude-code-integration.md](docs/claude-code-integration.md) for setup instructions with Claude Code.
|
|
305
|
+
|
|
306
|
+
## Tips & Known Issues
|
|
307
|
+
|
|
308
|
+
- **Login verification**: `check_login_status` has a DOM detection bug — use `search_feeds` with any keyword to verify login state
|
|
309
|
+
- **Post ID**: `publish_content` may return an empty PostID — this is normal. Use `search_feeds` with your username to verify
|
|
310
|
+
- **Don't retry publishing** — A timeout doesn't mean failure. Always verify before retrying
|
|
311
|
+
- **Proxy required**: Outside China, the MCP server needs `-rod "proxy=..."` flag
|
|
312
|
+
- **Concurrent sessions**: Don't log in to the same account from both MCP and web browser simultaneously
|
|
313
|
+
- **`visibility` values**: Must be in Chinese: `公开可见`, `仅自己可见`, `仅互关好友可见`
|
|
314
|
+
- **`schedule_at` range**: Must be between 1 hour and 14 days from now
|
|
315
|
+
|
|
316
|
+
## Platform Support
|
|
317
|
+
|
|
318
|
+
| Component | macOS ARM64 | macOS x86 | Linux | Windows |
|
|
319
|
+
|-----------|:-----------:|:---------:|:-----:|:-------:|
|
|
320
|
+
| **xhs CLI** | ✅ | ✅ | ✅ | ✅ |
|
|
321
|
+
| MCP Server | ✅ | ❌ | ❌ | ❌ |
|
|
322
|
+
| CDP Scripts | ✅ | ✅ | ✅ | ✅ |
|
|
323
|
+
|
|
324
|
+
**Windows / Linux / macOS x86 users**: Run `xhs init` — the CLI auto-detects missing MCP binary and switches to **CDP-only mode**. All features (publish, search, analytics, etc.) work through Chrome.
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
# Windows
|
|
328
|
+
setup.bat # One-click install
|
|
329
|
+
activate.bat && xhs init # Initialize (auto CDP mode)
|
|
330
|
+
|
|
331
|
+
# macOS / Linux
|
|
332
|
+
bash setup.sh
|
|
333
|
+
source activate.sh && xhs init
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Project Structure
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
xiaohongshu/
|
|
340
|
+
├── README.md # This file
|
|
341
|
+
├── SKILL.md # OpenClaw skill definition
|
|
342
|
+
├── pyproject.toml # CLI package config (pip install -e .)
|
|
343
|
+
├── manifest.json # Skill metadata
|
|
344
|
+
├── LICENSE # MIT License
|
|
345
|
+
├── requirements.txt # Python dependencies (legacy)
|
|
346
|
+
├── .gitignore
|
|
347
|
+
├── src/xhs_cli/ # ⭐ CLI package
|
|
348
|
+
│ ├── main.py # Unified entry point (xhs command)
|
|
349
|
+
│ ├── engines/
|
|
350
|
+
│ │ ├── mcp_client.py # MCP JSON-RPC client (auto session)
|
|
351
|
+
│ │ └── cdp_client.py # CDP scripts wrapper
|
|
352
|
+
│ ├── commands/
|
|
353
|
+
│ │ ├── init.py # xhs init (guided setup)
|
|
354
|
+
│ │ ├── auth.py # xhs login/logout/status
|
|
355
|
+
│ │ ├── publish.py # xhs publish (auto engine)
|
|
356
|
+
│ │ ├── search.py # xhs search/detail
|
|
357
|
+
│ │ ├── interact.py # xhs like/comment/favorite
|
|
358
|
+
│ │ ├── analytics.py # xhs analytics/notifications
|
|
359
|
+
│ │ ├── account.py # xhs account management
|
|
360
|
+
│ │ ├── profile.py # xhs me/profile
|
|
361
|
+
│ │ ├── server.py # xhs server start/stop/status
|
|
362
|
+
│ │ └── config_cmd.py # xhs config show/set/get
|
|
363
|
+
│ └── utils/
|
|
364
|
+
│ ├── config.py # ~/.xhs/config.json management
|
|
365
|
+
│ └── output.py # Rich formatted output
|
|
366
|
+
├── mcp/
|
|
367
|
+
│ ├── xiaohongshu-mcp-darwin-arm64 # MCP server binary
|
|
368
|
+
│ ├── xiaohongshu-login-darwin-arm64 # Login helper binary
|
|
369
|
+
│ └── start.sh # Startup script
|
|
370
|
+
├── scripts/
|
|
371
|
+
│ ├── cdp_publish.py # Main CDP automation (2700 lines)
|
|
372
|
+
│ ├── chrome_launcher.py # Chrome lifecycle management
|
|
373
|
+
│ ├── publish_pipeline.py # High-level publish workflow
|
|
374
|
+
│ ├── feed_explorer.py # Feed browsing utilities
|
|
375
|
+
│ ├── account_manager.py # Multi-account management
|
|
376
|
+
│ ├── image_downloader.py # Image download helper
|
|
377
|
+
│ └── run_lock.py # Process locking
|
|
378
|
+
├── config/
|
|
379
|
+
│ └── accounts.json.example # Account config template
|
|
380
|
+
└── docs/
|
|
381
|
+
├── cli-guide.md # ⭐ CLI usage guide
|
|
382
|
+
└── claude-code-integration.md # Claude Code setup guide
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Contributing
|
|
386
|
+
|
|
387
|
+
Issues and PRs welcome! Areas where help is needed:
|
|
388
|
+
|
|
389
|
+
- [ ] Cross-platform MCP builds (Linux, Windows, macOS x86)
|
|
390
|
+
- [ ] MCP Go source code release
|
|
391
|
+
- [ ] Video upload improvements
|
|
392
|
+
- [ ] Rate limiting and retry logic
|
|
393
|
+
- [ ] Test suite
|
|
394
|
+
|
|
395
|
+
## License
|
|
396
|
+
|
|
397
|
+
[MIT](./LICENSE)
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
<p align="center">
|
|
402
|
+
<sub>Built with ❤️ by <a href="https://github.com/Youhai020616">Youhai</a></sub>
|
|
403
|
+
</p>
|