When using this skill, treat it first as a standalone Xiaohongshu workflow toolbox, not as a thin wrapper around the original repository.
Execution flow
-
First confirm the runtime environment. Use
skills/xhs-search-workflow/scripts/setup_env.shto initialize dependencies. When executing scripts, prefer usingskills/xhs-search-workflow/.venv/bin/python. When you need full installation, common commands, or validation commands, openreferences/quickstart.md。 -
First decide on the authentication method. When a valid
COOKIESalready exists, directly use--cookieor--env-file. When there is no login state, runxhs_full_cli.py loginfor QR code login. QR code login will automatically bootstrap an anonymous-state cookie, generate a terminal QR code and a local PNG image, and save the successful session locally tocookies.json. When you need to manually capture cookies, view QR code login details, or troubleshoot login failures, openreferences/quickstart.mdandreferences/troubleshooting.md。
-
Choose the entry script according to the task.
scripts/xhs_full_cli.py: unified entry point, preferred for general tasks such as login, status checks, users, comments, messages, home page, creators, and watermark-free links.scripts/search_notes.py: only performs note search.scripts/fetch_note_texts.py: extracts titles, body text, and image links, or downloads watermark-free images.scripts/export_notes.py: exports Excel and media files. -
Follow the default media download policy. Once the user explicitly requests downloading images, videos, or media packages, use watermark-free links by default. Only use the original media address when the user explicitly requests keeping the original links or the watermarked version.
-
Control the output method. For interfaces with large return volumes, prefer using
--outto write files. When batch export is needed, prefer usingexport_notes.py. When more reliable scraping is needed, keep the throttling and retry parameters offetch_note_texts.py.
Key resources
-
references/quickstart.mdOpen when you need installation, authentication, common commands, CLI subcommands, or validation commands. -
references/troubleshooting.mdOpen when encountering risk control, expired login, empty results, API exceptions, or environment issues. -
scripts/xhs_auth.pyResponsible for QR code login, local session saving, and QR code image generation. -
scripts/xhs_client.pyResponsible for signed requests, cookie handling, and unified API request encapsulation. -
assets/js/Stores offline signing and the JS resources needed for running. Do not deleteassets/js/vendor/crypto-js.js。
Constraints
- Do not depend on the original repository's
Spider_XHSruntime modules. - Do not leak cookies, session files, or screenshots into chats, logs, or Git repositories.
- Do not treat the system Python as the default interpreter unless you have confirmed the environment is compatible.
- Do not switch to a watermarked media path without explanation.