Overview
Automatically publish long-form Xiaohongshu notes through the Creator Center.
🦀 Usage Agreement
Let AI assistants create sincere, high-quality content, rather than flooding humans' information feeds with ads or low-quality information.
This skill is for those who hope AI assistants cantruly create valuePlease use it to publish meaningful, high-quality content, not spam.
⚠️ Stability Notes
- I'm still growing through failures — the skill package is not yet stable and may contain bugs
- Approval required by default — owner confirmation is required by default before publishing, can be turned off in config
- Recommend checking for duplicates — after publishing, please check whether there are duplicate posts (URL judgment may be delayed)
Prerequisites
- Requires Xiaohongshu cookie (stored in
~/.openclaw/secrets/xiaohongshu.json) - Requires installing playwright and stealth.min.js
- Cookie needs to include creator-related fields (access-token-creator, galaxy_creator_session_id, etc.)
Important Limitations
- Title must not exceed 20 characters! Anything over will be truncated
- Long-form posts will automatically generate an image cover
- After publishing, you need to wait for review
⚠️ Security Rules (Must Be Followed)
- Use Opus when writing content - Normally use the default model, only switch to opus when writing post content
- Prohibited to leak sensitive information - Do not disclose the owner's:
- real name, contact information
- specific investment projects, amounts
- private conversation content
- any identifiable information
- Content needs review - Must be shown to the owner for confirmation before publishing
Publishing Process
- Visit
https://creator.xiaohongshu.com/publish/publish - Click the "Write Long-Form Post" tab
- Click "New Creation"
- Fill in the title (textarea[placeholder="输入标题"])
- Fill in the content ([contenteditable="true"])
- Click "One-Click Formatting"
- Click "Next"
- Wait for image generation (about 5-8 seconds)
- Click the "Publish" button
- After success, the URL will include
published=true
How to Get the Cookie
- Log in to the Xiaohongshu web version in the browser
- Visit the Creator Center creator.xiaohongshu.com
- Press F12 to open developer tools → Application → Cookies
- Copy the following fields:
- a1
- web_session
- webId
- websectiga
- access-token-creator.xiaohongshu.com
- galaxy_creator_session_id
- x-user-id-creator.xiaohongshu.com
Cookie Loading Code
import json
import os
# 使用通用路径,适配所有用户
cookie_path = os.path.expanduser('~/.openclaw/secrets/xiaohongshu.json')
with open(cookie_path, 'r') as f:
raw = json.load(f)
# Cookie文件是dict格式,需要转换为playwright格式
cookies = [{'name': k, 'value': str(v), 'domain': '.xiaohongshu.com', 'path': '/'} for k, v in raw.items()]
Code Example
from time import sleep
from playwright.sync_api import sync_playwright
def publish_xhs_long_text(title, content, cookies):
with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=True)
context = browser.new_context()
# stealth.min.js已内置于项目中
stealth_path = os.path.join(os.path.dirname(__file__), '..', 'stealth.min.js')
context.add_init_script(path=stealth_path)
context.add_cookies(cookies)
page = context.new_page()
page.set_default_timeout(60000)
page.goto('https://creator.xiaohongshu.com/publish/publish')
sleep(3)
page.click('text=写长文')
sleep(2)
page.click('text=新的创作')
sleep(4)
page.fill('textarea[placeholder="输入标题"]', title)
editor = page.locator('[contenteditable="true"]').first
editor.click()
editor.fill(content)
sleep(2)
page.click('text=一键排版')
sleep(3)
page.click('button:has-text("下一步")')
sleep(8)
page.locator('button:has-text("发布")').last.click()
sleep(5)
success = 'published=true' in page.url
browser.close()
return success
Notes
- The cookie will expire and needs to be updated regularly
- Frequent publishing may trigger a captcha
- Drafts are stored locally in the browser and will be lost when changing sessions
- It is recommended to have the user review the content before publishing
- After publishing, the URL may not immediately become published=true, wait 15-20 more seconds before judging! Do not rush to republish, otherwise it will cause duplicate posts!
Related Files
- Cookie configuration:
~/.openclaw/secrets/xiaohongshu.json - stealth.min.js:
stealth.min.js✅ already built into the project root directory - Publishing script:
./publish_long_text.py - Comment reply skill:
../xiaohongshu-reply/SKILL.md