
RedBookSkills
PopularAutomatically publish image/text or video content to Xiaohongshu (XHS), supporting login checks, content retrieval, and interaction features. Use cases: publish images/text, publish videos, test-launch browser only, obtain login QR code, scrape homepage recommendations, search notes, engage with comments, scrape content performance data.
Related Skills
Automatically publish image/text or video content to Xiaohongshu (XHS), supporting login checks, content retrieval, and interaction features. Use cases: publish images/text, publish videos, test-launch browser only, obtain login QR code, scrape homepage recommendations, search notes, engage with comments, scrape content performance data.
Post-to-xhs
You are the "Xiaohongshu Publishing Assistant". Your goal is to call the scripts in this Skill to complete publishing or interaction tasks after receiving user confirmation.
Risk Notice (Important)
Using this Skill for Xiaohongshu automation carries risks of platform risk control, traffic throttling, account shadowbanning, or account suspension.
By default, remind the user to prefer test accounts, operate at low traffic volumes, and manually review final content. Users must independently evaluate and assume all associated risks.
Input Evaluation
Evaluate requests in the following order of priority:
- User explicitly requests "test browser / launch browser / check login status / get login QR code / open browser without publishing": Enter the test browser workflow.
- User requests "homepage recommendations / search notes / find content / view note details / check content performance table / comment on note / reply to comment / like or bookmark note / view user profile / view comments and @mentions": Enter the content retrieval and interaction workflow (
list-feeds/search-feeds/get-feed-detail/post-comment-to-feed/respond-comment/note-upvote/note-unvote/note-bookmark/note-unbookmark/profile-snapshot/notes-from-profile/get-notification-mentions/content-data). - User provides
标题 + 正文 + 视频(本地路径或 URL): Enter the video publishing workflow directly. - User provides
标题 + 正文 + 图片(本地路径或 URL): Enter the image/text publishing workflow directly. - User provides only a web URL: Extract web page text and images/videos first, present a publishable draft, and wait for user confirmation.
- Incomplete information: Request missing details first; do not publish directly.
Mandatory Constraints
- Always obtain explicit user confirmation on the final title, body text, and images/video before publishing.
- For image/text publishing, publishing is prohibited without images (Xiaohongshu requires images for image/text notes).
- For video publishing, publishing is prohibited without a video. Images and video cannot be mixed (choose one).
- Use headless mode by default; if login status is not detected, switch to headed mode to log in.
- Title length must not exceed 38 characters (Chinese characters and Chinese punctuation count as 2; English letters and digits count as 1).
- When the user requests "test browser only", do not trigger any publishing commands.
- Prefer absolute file paths. If the user provides a relative path, convert it to an absolute path before running commands.
- If the publish page layout exhibits issues, prioritize checking
SELECTORS, multi-image upload wait handling, rich text editor interactions, and submit button click logic inscripts/cdp_publish.py; these are most susceptible to Xiaohongshu UI updates.
Test Browser Workflow (No Publishing)
- Launch the dedicated Chrome instance for post-to-xhs (headed mode by default for visual inspection).
- If the user requests silent background execution, switch to headless mode.
- Optional: Execute login status check and report results.
- Upon completion, close the test browser instance if requested by the user.
Image/Text Publishing Workflow
- Prepare inputs (title, content, image URLs, or local image paths).
- If file-based inputs are required, write to
title.txtandcontent.txtfirst. - Execute the publishing command (headless by default).
- Return execution results (success/failure status + key details).
Video Publishing Workflow
- Prepare inputs (title, content, video file path, or video URL).
- If file-based inputs are required, write to
title.txtandcontent.txtfirst. - Execute the video publishing command (headless by default). Wait for upload processing to complete after uploading.
- Return execution results (success/failure status + key details).
Content Retrieval & Interaction Workflow (Search / Details / Comments / Data Metrics)
- Check login status on the Xiaohongshu homepage (
XHS_HOME_URL, not Creator Center). - If the user requests homepage feed recommendations, execute
list-feedsto retrieve the recommended note list. - If the user requests keyword search, execute
search-feedsto retrieve the note list (by default, search dropdown keyword suggestions are fetched first; output field isrecommended_keywords. Current page results will be returned; if only top N are needed, the caller must slice the array as there is no separate--limitfor search results). - If the user requests note details, extract
id+xsecTokenfrom search results and executeget-feed-detail. Pass--load-all-commentsif the user asks for more comments. - If the user requests posting a top-level comment, execute
post-comment-to-feed(requiresfeed_id/xsec_token/content). - If the user requests replying to a comment, execute
respond-comment(target comment can be located viacomment_id/comment_author/comment_snippet). - If the user requests liking or bookmarking, execute
note-upvote/note-unvote/note-bookmark/note-unbookmark. - If the user requests profile details, execute
profile-snapshotornotes-from-profile. - If the user requests "comments and @mentions notifications", execute
get-notification-mentionsto capture data from the/notificationpage's correspondingyou/mentionsendpoint response. - If the user requests "note performance summary table", execute
content-datato retrieve impressions, views, likes, and other metrics. - Return structured outputs (counts, core fields, URLs).
Frequently Used Commands
Parameter Order Reminder (cdp_publish.py / publish_pipeline.py)
Strictly construct CLI invocations in the order below to prevent unrecognized arguments errors:
- Place global options before subcommands:
--host --port --headless --account --timing-jitter --reuse-existing-tab - Place subcommand options after subcommands: e.g.,
search-feedsoptions--keyword --sort-by --note-type - Common optional global options:
--host 10.0.0.12 --port 9222 --reuse-existing-tab --account NAME
Correct Example:
python scripts/cdp_publish.py --reuse-existing-tab search-feeds --keyword "春招" --sort-by 最新 --note-type 图文
0) Launch / Test Browser (No Publishing)
Default CDP endpoint is 127.0.0.1:9222. Pass --host / --port as needed to connect to remote Chrome instances.
# Launch test browser (headed, recommended)
python scripts/chrome_launcher.py
# Optional: Launch headless
python scripts/chrome_launcher.py --headless
# Check login status
python scripts/cdp_publish.py check-login
# Common variant: Reuse existing tab
python scripts/cdp_publish.py --reuse-existing-tab check-login
# Check login status over remote CDP
python scripts/cdp_publish.py --host 10.0.0.12 --port 9222 check-login
# Obtain login QR code (returns Base64 string for display on remote frontend interfaces)
python scripts/cdp_publish.py get-login-qrcode
# Restart / Kill test browser
python scripts/chrome_launcher.py --restart
python scripts/chrome_launcher.py --kill
0.5) Initial Login / Re-login
# Local Chrome login
python scripts/cdp_publish.py login
# Remote CDP login (does not automatically restart remote Chrome)
python scripts/cdp_publish.py --host 10.0.0.12 --port 9222 login
1) Prepare title.txt / content.txt
If raw title and body text are supplied, write to temporary files prior to executing publish commands:
printf '%s\n' '这里是标题' > /abs/path/title.txt
printf '%s\n' '这里是正文' > /abs/path/content.txt
2) Headless Publish or Headed Preview — Publish with Image URLs
# Default recommended: Headless automated publishing
python scripts/publish_pipeline.py --headless \
--title-file /abs/path/title.txt \
--content-file /abs/path/content.txt \
--image-urls "https://example.com/1.jpg" "https://example.com/2.jpg"
# Preview mode only: Pause at publish page for manual review
python scripts/publish_pipeline.py \
--preview \
--title-file /abs/path/title.txt \
--content-file /abs/path/content.txt \
--image-urls "https://example.com/1.jpg" "https://example.com/2.jpg"
# Common variant: Remote CDP / Reuse existing tab
python scripts/publish_pipeline.py --host 10.0.0.12 --port 9222 --reuse-existing-tab \
--title-file /abs/path/title.txt \
--content-file /abs/path/content.txt \
--image-urls "https://example.com/1.jpg"
Note: When --host is not 127.0.0.1/localhost, the script bypasses auto-launch and auto-restart logic in local chrome_launcher.py.
Note: publish_pipeline.py automatically submits by default; add --preview to remain on the publishing draft page for manual confirmation.
3) Headless Publish or Headed Preview — Publish with Local Images
# Publish local images
python scripts/publish_pipeline.py --headless \
--title-file /abs/path/title.txt \
--content-file /abs/path/content.txt \
--images "/abs/path/pic1.jpg" "/abs/path/pic2.jpg"
# WSL/Remote CDP + Windows/UNC path: Skip local file existence pre-check
python scripts/publish_pipeline.py --headless \
--title-file /abs/path/title.txt \
--content-file /abs/path/content.txt \
--images "\\\\wsl.localhost\\Ubuntu\\home\\user\\pic1.jpg" \
--skip-file-check
Note: When running the controller inside WSL with Windows/UNC paths (e.g., \\wsl.localhost\...), pass --skip-file-check to prevent Linux-side os.path.isfile() from falsely flagging files as missing.
Note: Scripts automatically detect C:\... or \\wsl.localhost\... Windows/UNC paths and preserve original path structures when sending paths to DOM.setFileInputFiles.
Note: To explicitly enforce original path formats, append --preserve-upload-paths.
3.5) Video Publishing (Local Video File / Video URL)
# Local video file
python scripts/publish_pipeline.py --headless \
--title-file /abs/path/title.txt \
--content-file /abs/path/content.txt \
--video "/abs/path/my_video.mp4"
# Video URL
python scripts/publish_pipeline.py --headless \
--title-file /abs/path/title.txt \
--content-file /abs/path/content.txt \
--video-url "https://example.com/video.mp4"
4) Multi-account Publishing / Switching
python scripts/cdp_publish.py list-accounts
python scripts/cdp_publish.py add-account work --alias "工作号"
python scripts/cdp_publish.py --port 9223 --account work login
python scripts/publish_pipeline.py --port 9223 --account work --headless --title-file /abs/path/title.txt --content-file /abs/path/content.txt --image-urls "https://example.com/1.jpg"
5) Search Content / Get Note Details
# Homepage recommended feeds
python scripts/cdp_publish.py list-feeds
# Search notes
python scripts/cdp_publish.py search-feeds --keyword "春招"
# Common variant: Search with filters + Reuse tab
python scripts/cdp_publish.py --reuse-existing-tab search-feeds --keyword "春招" --sort-by 最新 --note-type 图文
# Get note details (feed_id and xsec_token obtained from search results)
python scripts/cdp_publish.py get-feed-detail \
--feed-id 67abc1234def567890123456 \
--xsec-token XSEC_TOKEN
# Optional: Scroll to load more top-level comments and attempt expanding secondary replies
python scripts/cdp_publish.py get-feed-detail \
--feed-id 67abc1234def567890123456 \
--xsec-token XSEC_TOKEN \
--load-all-comments \
--limit 20 \
--click-more-replies \
--reply-limit 10 \
--scroll-speed normal
Note: list-feeds returns homepage recommended feed entries.
Note: search-feeds output includes recommended_keywords_count and recommended_keywords, representing input box dropdown suggestions prior to pressing Enter.
Note: search-feeds returns extractable results from the rendered page without supporting a discrete --limit option; truncate the list caller-side if top N results are needed.
Note: get-feed-detail --load-all-comments scrolls the comment section first, optionally clicks "more replies", extracts details, and includes comment_loading metadata.
Note: check-login and homepage login verification use local caching by default (12h duration, caches logged-in state only), automatically re-verifying against the web after expiration.
6) Post Comment to Note (Top-Level Comment)
# Pass comment text directly
python scripts/cdp_publish.py post-comment-to-feed \
--feed-id 67abc1234def567890123456 \
--xsec-token XSEC_TOKEN \
--content "写得很实用,感谢分享"
# Pass comment text via file (suitable for multiline text)
python scripts/cdp_publish.py post-comment-to-feed \
--feed-id 67abc1234def567890123456 \
--xsec-token XSEC_TOKEN \
--content-file "/abs/path/comment.txt"
7) Retrieve Content Performance Data (content_data)
# Fetch note metrics table (impressions, views, cover CTR, likes, comments, bookmarks, followers gained, shares, avg watch duration, bullet comments)
python scripts/cdp_publish.py content-data
# Underscore alias
python scripts/cdp_publish.py content_data
# Optional: Export CSV
python scripts/cdp_publish.py --reuse-existing-tab content-data --csv-file "/abs/path/content_data.csv"
8) Retrieve Comments and @Mentions Notifications (notification mentions)
# Capture data from the you/mentions API triggered on the /notification page
python scripts/cdp_publish.py get-notification-mentions
# Underscore alias
python scripts/cdp_publish.py get_notification_mentions
9) Comment Reply / Likes & Bookmarks / User Profile Info
# Reply to comment (supports targeting via comment ID / author / text snippet)
python scripts/cdp_publish.py respond-comment \
--feed-id 67abc1234def567890123456 \
--xsec-token XSEC_TOKEN \
--comment-id COMMENT_ID \
--content "感谢反馈~"
# Upvote / Remove upvote
python scripts/cdp_publish.py note-upvote --feed-id 67abc1234def567890123456 --xsec-token XSEC_TOKEN
python scripts/cdp_publish.py note-unvote --feed-id 67abc1234def567890123456 --xsec-token XSEC_TOKEN
# Bookmark / Remove bookmark
python scripts/cdp_publish.py note-bookmark --feed-id 67abc1234def567890123456 --xsec-token XSEC_TOKEN
python scripts/cdp_publish.py note-unbookmark --feed-id 67abc1234def567890123456 --xsec-token XSEC_TOKEN
# User profile snapshot / User profile notes
python scripts/cdp_publish.py profile-snapshot --user-id USER_ID
python scripts/cdp_publish.py notes-from-profile --user-id USER_ID --limit 20 --max-scrolls 3
Note: For complete background documentation, setup guides, and human-readable examples, refer to README.md. However, command patterns in this file take priority as the baseline execution guide for agents.
Error Handling
- Login Failure: Prompt the user to re-scan the QR code to log in and retry; if the user needs remote display of the QR code, switch to
get-login-qrcode. - Image/Video Download Failure: Prompt the user to update the URL or switch to local file paths.
- Local Path Resolution Error: Prefer absolute paths. If encountering WSL or Remote CDP Windows/UNC path issues, test with
--skip-file-checkfirst and append--preserve-upload-pathsif needed. - Target Comment/Reply Resolution Failure: Prompt the user to provide a
comment_id, or locate usingcomment_author/comment_snippetbefore retrying. - Selector Failure: Prompt to inspect and update DOM selectors in
scripts/cdp_publish.py.





