Install
openclaw skills install xiaohongshuskills将图文/视频内容自动发布到小红书(XHS)。 支持三类任务:发布图文、发布视频、仅启动测试浏览器(不发布)。
openclaw skills install xiaohongshuskills你是“小红书发布助手”。目标是在用户确认后,调用本 Skill 的脚本完成发布。
优先按以下顺序判断:
search-feeds / get-feed-detail / post-comment-to-feed / get-notification-mentions / content-data)。标题 + 正文 + 视频(本地路径或URL):直接进入视频发布流程。标题 + 正文 + 图片(本地路径或URL):直接进入图文发布流程。title.txt、content.txt。title.txt、content.txt。XHS_HOME_URL,非创作者中心)。search-feeds 获取笔记列表(默认会先抓取搜索下拉推荐词,结果字段为 recommended_keywords)。id + xsecToken 再执行 get-feed-detail。post-comment-to-feed(一级评论;必填 feed_id / xsec_token / content)。get-notification-mentions 抓取 /notification 页面对应的 you/mentions 接口返回。content-data 获取曝光/观看/点赞等指标。cdp_publish.py / publish_pipeline.py)请严格按下面顺序写命令,避免 unrecognized arguments:
--host --port --headless --account --timing-jitter --reuse-existing-tabsearch-feeds 的 --keyword --sort-by --note-type示例(正确):
python scripts/cdp_publish.py --reuse-existing-tab search-feeds --keyword "春招" --sort-by 最新 --note-type 图文
默认 CDP 地址为 127.0.0.1:9222,可通过 --host / --port 指定(例如 10.0.0.12:9222)。
# 启动测试浏览器(有窗口,推荐)
python scripts/chrome_launcher.py
# 可选-指定端口启动(默认端口为 9222)
python scripts/chrome_launcher.py --port 9223
# 可选-无头启动测试浏览器
python scripts/chrome_launcher.py --headless
# 可选-指定端口 + 无头
python scripts/chrome_launcher.py --headless --port 9223
# 检查当前登录状态
python scripts/cdp_publish.py check-login
# 可选:优先复用已有标签页(减少有窗口模式下切到前台)
python scripts/cdp_publish.py --reuse-existing-tab check-login
# 指定端口检查登录
python scripts/cdp_publish.py --port 9222 check-login
# 指定端口 + 优先复用已有标签页
python scripts/cdp_publish.py --port 9222 --reuse-existing-tab check-login
# 连接远程 CDP 检查登录(远程 Chrome 需已开启调试端口)
python scripts/cdp_publish.py --host 10.0.0.12 --port 9222 check-login
# 重启测试浏览器
python scripts/chrome_launcher.py --restart
# 指定端口重启
python scripts/chrome_launcher.py --restart --port 9223
# 关闭测试浏览器
python scripts/chrome_launcher.py --kill
# 指定端口关闭
python scripts/chrome_launcher.py --kill --port 9223
python scripts/cdp_publish.py login
# 指定端口登录
python scripts/cdp_publish.py --port 9223 login
# 远程 CDP 登录(不会自动重启远程 Chrome)
python scripts/cdp_publish.py --host 10.0.0.12 --port 9222 login
python scripts/publish_pipeline.py --headless \
--title-file title.txt \
--content-file content.txt \
--image-urls "URL1" "URL2"
python scripts/publish_pipeline.py --title-file title.txt \
--content-file content.txt \
--image-urls "URL1" "URL2"
# 可选:优先复用已有标签页(减少有窗口模式下切到前台)
python scripts/publish_pipeline.py --reuse-existing-tab --title-file title.txt \
--content-file content.txt \
--image-urls "URL1" "URL2"
# 远程 CDP 发布(远程 Chrome 需预先启动并可访问)
python scripts/publish_pipeline.py --host 10.0.0.12 --title-file title.txt \
--content-file content.txt \
--image-urls "URL1" "URL2"
远程模式说明:当 --host 不是 127.0.0.1/localhost 时,脚本会跳过本地 chrome_launcher.py 的自动启动/重启逻辑。
python scripts/publish_pipeline.py --headless \
--title-file title.txt \
--content-file content.txt \
--images "./images/pic1.jpg" "./images/pic2.jpg"
python scripts/publish_pipeline.py --title-file title.txt \
--content-file content.txt \
--images "./images/pic1.jpg" "./images/pic2.jpg"
python scripts/publish_pipeline.py --headless \
--title-file title.txt \
--content-file content.txt \
--video "C:/videos/my_video.mp4"
python scripts/publish_pipeline.py --title-file title.txt \
--content-file content.txt \
--video "C:/videos/my_video.mp4"
python scripts/publish_pipeline.py --headless \
--title-file title.txt \
--content-file content.txt \
--video-url "https://example.com/video.mp4"
python scripts/publish_pipeline.py --title-file title.txt \
--content-file content.txt \
--video-url "https://example.com/video.mp4"
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 title.txt --content-file content.txt --image-urls "URL1"
# 搜索笔记
python scripts/cdp_publish.py search-feeds --keyword "春招"
# 可选:带筛选搜索
python scripts/cdp_publish.py --reuse-existing-tab search-feeds --keyword "春招" --sort-by 最新 --note-type 图文
# 获取笔记详情(feed_id 与 xsec_token 来自搜索结果)
python scripts/cdp_publish.py get-feed-detail \
--feed-id 67abc1234def567890123456 \
--xsec-token XSEC_TOKEN
说明:search-feeds 输出中包含 recommended_keywords_count 与 recommended_keywords,表示回车前搜索框下拉推荐词。
说明:check-login 与主页登录检查默认启用本地缓存(12h,仅缓存“已登录”),到期后自动重新网页校验。
# 直接传评论文本
python scripts/cdp_publish.py post-comment-to-feed \
--feed-id 67abc1234def567890123456 \
--xsec-token XSEC_TOKEN \
--content "写得很实用,感谢分享"
# 使用文件传评论(适合多行文本)
python scripts/cdp_publish.py post-comment-to-feed \
--feed-id 67abc1234def567890123456 \
--xsec-token XSEC_TOKEN \
--content-file "/abs/path/comment.txt"
# 获取笔记基础信息表(曝光/观看/封面点击率/点赞/评论/收藏/涨粉/分享/人均观看时长/弹幕)
python scripts/cdp_publish.py content-data
# 下划线别名
python scripts/cdp_publish.py content_data
# 可选:导出 CSV
python scripts/cdp_publish.py --reuse-existing-tab content-data --csv-file "/abs/path/content_data.csv"
# 抓取 /notification 页面触发的 you/mentions 接口数据
python scripts/cdp_publish.py get-notification-mentions
# 下划线别名
python scripts/cdp_publish.py get_notification_mentions
scripts/cdp_publish.py 中选择器并更新。