Install
openclaw skills install xiaohongshu-note-fetcher抓取并整理小红书笔记公开页面信息(标题、正文摘要、作者、发布时间、互动数据、标签、封面图等)为结构化 JSON 或 Markdown。用于“根据笔记链接提取内容”“批量收集笔记基础信息”“生成笔记摘要素材”等场景;当用户提供小红书笔记 URL、URL 列表或需要导出机器可读结果时触发。
openclaw skills install xiaohongshu-note-fetcher输入 TikHub API Key + 需求(关键词、页码) 即可抓取小红书搜索数据。
最小示例:
make tikhub-fetch \
KEYWORD="女性力量" \
TIKHUB_PAGE=2 \
TIKHUB_TOKEN="<YOUR_TIKHUB_KEY>" \
TIKHUB_ENDPOINT=web \
TIKHUB_AUTH_MODE=bearer
输出文件:
workspace/xiaohongshu-note-fetcher-skill-data/tikhub_search_page2.jsonpython3 scripts/fetch_xiaohongshu_notes.py \
--url "https://www.xiaohongshu.com/explore/<note_id>" \
--format both \
--output result.json
python3 scripts/fetch_xiaohongshu_notes.py \
--url-file ./urls.txt \
--format json \
--output notes.json
python3 scripts/search_notes_tikhub.py \
--token "<YOUR_TIKHUB_TOKEN>" \
--keyword "女性主义" \
--page 1 \
--output search_page1.json
也可以使用 Makefile 一键调用(推荐长期使用):
make tikhub-fetch \
KEYWORD="美食" \
TIKHUB_TOKEN="<YOUR_TIKHUB_TOKEN>" \
TIKHUB_ENDPOINT=web \
TIKHUB_AUTH_MODE=bearer
若你不想每次手输 token,可把 token 放到文件(如 ./.tikhub_token):
make tikhub-fetch \
KEYWORD="美食" \
TIKHUB_TOKEN_FILE=./.tikhub_token \
TIKHUB_ENDPOINT=web \
TIKHUB_AUTH_MODE=bearer
python3 scripts/search_notes_generic.py \
--base-url "https://your-api.example.com/search_notes" \
--auth-mode bearer \
--auth-header Authorization \
--token "<YOUR_API_TOKEN>" \
--keyword "美食推荐" \
--page 1 \
--param sort_type=general \
--output generic_search.json
python3 scripts/build_article_list_from_tikhub.py \
--input ./tikhub_search.json \
--min-likes 1000 \
--rank-by hot \
--md-output ./xhs_article_list.md \
--csv-output ./xhs_article_list.csv \
--json-output ./xhs_article_list.json \
--template-output ./xhs_publish_templates.md
python3 scripts/build_article_list_from_tikhub.py \
--token "<YOUR_TIKHUB_TOKEN>" \
--keyword "美食" \
--pages 5 \
--sort general \
--note-type _0 \
--min-likes 1000 \
--rank-by hot \
--top 50
python3 scripts/interactive_filter_view.py \
--input ./tikhub_search.json
直接回车会采用默认方案:
1000hot(综合热度)20summarymd/csv若你不想交互,直接用默认方案:
python3 scripts/interactive_filter_view.py \
--input ./tikhub_search.json \
--non-interactive
python3 scripts/generate_wow_pack.py \
--input ./xhs_article_list.json \
--keyword 美食 \
--url-output ./xhs_topic_mindmap_url.txt
node scripts/fetch_xiaohongshu_note_playwright.js \
--url "https://www.xiaohongshu.com/explore/<note_id>" \
--cookie-file ./cookie.txt \
--output note_browser.json \
--screenshot note_browser.png \
--html-out note_browser.html
若首次运行提示 playwright_not_installed,先安装:
cd scripts
npm i playwright
npx playwright install chromium
--url: 单条小红书笔记 URL。--url-file: 批量 URL 文件(每行一个 URL,支持 # 注释行)。--cookie: 原始 Cookie 请求头字符串。--cookie-file: Cookie 文件(纯文本 Cookie 字符串)。--format: json、md、both,默认 json。--output: 输出路径;json/both 写该文件,md 会在同目录生成 .md。--timeout: 请求超时秒数,默认 20。search_notes_tikhub.py 关键参数:--keyword、--page 必填。--sort-type 可选:general、time_descending、popularity_descending 等。--note-type 支持中英文:不限/all、视频笔记/video、普通笔记/image、直播笔记/live。--time-filter 支持中英文:不限/all、一天内/day、一周内/week、半年内/half_year。--ai-mode 使用整数 0 或 1。search_notes_generic.py 关键参数:--base-url:新 API 的搜索端点。--auth-mode:none、bearer、apikey。--auth-header:鉴权头名称,默认 Authorization。--keyword-param / --page-param:当对方字段不是 keyword/page 时改这里。--param key=value:补充任意查询参数,可重复。--header key=value:补充任意请求头,可重复。fetch_xiaohongshu_note_playwright.js 关键参数:--url:笔记 URL。--cookie-file:浏览器 Cookie 文本(建议提供,提高字段完整度)。--headed:显示浏览器窗口调试。--screenshot / --html-out:输出调试文件,方便排查风控页和登录页。--url 与 --url-file 至少给一个。
og:title、og:description、og:image)noteId(若存在)references/output-schema.md。--cookie 后重试。400 Request failed:keyword、page,确认成功后再加筛选项。page 用整数、ai_mode 用 0/1。search_id、search_session_id。