labali-xiaohongshu-export-user-post-links
Treat this skill as a layered system, not a single script.
Layer Contract
SKILL.md(this file) is the policy layer.- Define goals, constraints, success criteria, and boundaries.
references/architecture.mdis the strategy layer.- Define extraction model, pagination strategy, and fallback policy.
scripts/*.tsis the execution layer.- Implement browser startup, profile parsing, pagination scrolling, and output writing.
Required Constraints
- Use browser automation only.
- Do not use Xiaohongshu private APIs.
- Reuse manual-login session via unified Chrome CDP startup:
open -na "Google Chrome" --args --remote-debugging-port=9223 --user-data-dir="$HOME/.chrome-labali-no-proxy" --no-proxy-server. - Parse links from profile page state with pagination scrolling.
- Export links to a specified local file path.
NEVER
- Never write links to the output file without deduplication.
- Never stop scrolling based on a fixed count alone — continue until no new posts are discovered or an explicit end marker is present.
- Never report success based on action completion alone — verify the output file is written with at least one link.
Success Criteria
A run is successful only when all conditions hold:
- The profile is opened and parsed for post cards.
- Scrolling pagination continues until no new posts are discovered.
- Extracted links are deduplicated.
- Output file is written as plain text lines, with optional publish-time prefix.
Runtime Inputs
Use skill.yaml as the source of truth for input schema.
Operational Mode
- Default mode: guided browser flow + profile-state extraction + scroll pagination.
- Startup guidance:
- launch/reuse Chrome by unified CDP command,
- open Xiaohongshu home page first,
- if login is required, pause for manual login.
- Input guidance:
- if
profile_urlis missing, prompt interactively, - if
output_pathis missing, prompt interactively with default.
- if
- Export policy:
- default output links include
xsec_tokenandxsec_source=pc_user, - optional canonical-only mode can output
/explore/<note_id>URLs, - optional latest-only mode can stop early after enough non-sticky candidates are found,
- optional publish-time mode can prefix each exported line with
publish_time<TAB>.
- default output links include
If fallback or pagination decisions are unclear, load
references/architecture.md. If link-parsing strategy is unclear, loadreferences/plan.md.
Resources
- Architecture and standards:
references/architecture.md - Workflow map and extraction plan:
references/plan.md - Shared runtime and parser helpers:
scripts/core.ts - Main orchestration:
scripts/executor.ts - CLI entry:
scripts/run.ts - Regression checks:
tests/test_regression.sh