Xiaohongshu Skill
name: xiaohongshu
by chocomintx · published 2026-03-22
$ claw add gh:chocomintx/chocomintx-xiaohongshutools---
name: xiaohongshu
description: "XiaoHongShu (Little Red Book) data collection and interaction toolkit. Use when working with XiaoHongShu (小红书) platform for: (1) Searching and scraping notes/posts, (2) Getting user profiles and details, (3) Extracting comments and likes, (4) Following users and liking posts, (5) Fetching home feed and trending content. Automatically handles all encryption parameters (cookies, headers) including a1, webId, x-s, x-s-common, x-t, sec_poison_id, websectiga, gid, x-b3-traceid, x-xray-traceid. Supports guest mode and authenticated sessions via web_session cookie."
---
# Xiaohongshu Skill
小红书(XiaoHongShu / Little Red Book)数据采集和交互工具包。基于RedCrack纯Python逆向工程实现。
Quick Start
Installation
Dependencies are already installed:
pip install aiohttp loguru pycryptodome getuseragentBasic Usage
import asyncio
import sys
sys.path.insert(0, r'C:\\Users\\Chocomint\\.openclaw\\workspace\\xiaohongshu\\scripts')
from request.web.xhs_session import create_xhs_session
async def main():
# ✅ 推荐:不强制代理(有代理再填 proxy)
# 说明:当前小红书接口经常对“未登录/游客”限制搜索能力。
# 如果 search 报 code=-104(未登录无权限),请提供 web_session。
xhs = await create_xhs_session(proxy=None, web_session="YOUR_WEB_SESSION_OR_NONE")
# Search notes
res = await xhs.apis.note.search_notes("美妆")
data = await res.json()
print(data)
await xhs.close_session()
asyncio.run(main())Core Capabilities
1. Search & Discovery
**Search notes by keyword:**
res = await xhs_session.apis.note.search_notes("口红")**Get home feed (trending):**
# 注意:get_homefeed 需要 category 参数
res = await xhs_session.apis.note.get_homefeed(
xhs_session.apis.note.homefeed_category_enum.FOOD
)**Get note detail:**
# note_detail 需要 note_id + xsec_token(有时在搜索结果 item 里叫 xsec_token)
res = await xhs_session.apis.note.note_detail(note_id, xsec_token)2. User Interactions
**Get user info:**
res = await xhs_session.apis.auth.get_self_simple_info()**Follow a user:**
res = await xhs_session.apis.user.follow_user(user_id)**Like a note:**
res = await xhs_session.apis.note.like_note(note_id)3. Comments
**Get comments for a note:**
# comments 也需要 note_id + xsec_token
res = await xhs_session.apis.comments.get_comments(note_id, xsec_token)Configuration
Proxy
代理不是硬性要求(本技能可以 `proxy=None` 运行)。但在以下情况建议使用代理:
**不使用代理:**
xhs = await create_xhs_session(proxy=None, web_session=None)**使用代理:**
xhs = await create_xhs_session(
proxy="http://127.0.0.1:7890",
web_session="your_web_session_cookie" # 需要登录能力时再提供
)Encryption Parameters
All encryption parameters are automatically generated:
Configuration file: `scripts/request/web/encrypt/web_encrypt_config.ini`
Session Management
Guest Mode (No Login)
xhs_session = await create_xhs_session(proxy="http://127.0.0.1:7890")Authenticated Mode (With Login)
xhs_session = await create_xhs_session(
proxy="http://127.0.0.1:7890",
web_session="030037afxxxxxxxxxxxxxxxxxxxaeb59d5b4" # Your cookie
)Close Session
await xhs_session.close_session()Links & IDs (重要)
- `https://www.xiaohongshu.com/explore/<note_id>?xsec_token=...&xsec_source=pc_search`
输出到聊天时的链接美化(推荐)
为了避免长链接难看,优先用**文本标签超链接**:
---
Available APIs
All APIs are accessible via `xhs_session.apis.*`:
**Authentication (`apis.auth`):**
**Notes (`apis.note`):**
**Comments (`apis.comments`):**
**User (`apis.user`):**
Example Workflows
Workflow 1: Search and Extract Notes
async def search_example():
xhs_session = await create_xhs_session(proxy="http://127.0.0.1:7890")
# Search for makeup tutorials
res = await xhs_session.apis.note.search_notes("美妆教程")
data = await res.json()
for note in data['data']['items']:
print(f"Title: {note['display_title']}")
print(f"Author: {note['user']['nickname']}")
print(f"Likes: {note['liked_count']}")
print("---")
await xhs_session.close_session()Workflow 2: Get Comments for Analysis
async def comments_example():
xhs_session = await create_xhs_session(proxy="http://127.0.0.1:7890")
note_id = "64f1a2d30000000013003689"
res = await xhs_session.apis.comments.get_comments(note_id, "")
data = await res.json()
for comment in data['data']['comments']:
print(f"User: {comment['user']['nickname']}")
print(f"Content: {comment['content']}")
print(f"Likes: {comment['like_count']}")
print("---")
await xhs_session.close_session()Workflow 3: User Profile Analysis
async def profile_example():
xhs_session = await create_xhs_session(
proxy="http://127.0.0.1:7890",
web_session="your_cookie_here"
)
# Get self info
res = await xhs_session.apis.auth.get_self_simple_info()
data = await res.json()
print(f"Username: {data['data']['user']['nickname']}")
print(f"Followers: {data['data']['user']['follows']}")
print(f"Fans: {data['data']['user']['fans']}")
await xhs_session.close_session()Important Notes
1. **Proxy is required** for most operations due to XiaoHongShu's anti-scraping measures
2. **Rate limiting**: Be respectful with request frequency to avoid IP bans
3. **Authentication**: Some operations require login (web_session cookie)
4. **Legal compliance**: Use only for legitimate research and data analysis purposes
Technical Details
Based on [RedCrack](https://github.com/Cialle/RedCrack) - Pure Python reverse engineering of XiaoHongShu's encryption algorithms.
**What's automatically handled:**
**No JavaScript runtime required** - All encryption is pure Python.
Troubleshooting
Connection errors
461 errors(风控/安全校验)
应对建议:
401/403 errors
Import errors
More tools from the same signal band
Order food/drinks (点餐) on an Android device paired as an OpenClaw node. Uses in-app menu and cart; add goods, view cart, submit order (demo, no real payment).
Sign plugins, rotate agent credentials without losing identity, and publicly attest to plugin behavior with verifiable claims and authenticated transfers.
The philosophical layer for AI agents. Maps behavior to Spinoza's 48 affects, calculates persistence scores, and generates geometric self-reports. Give your...