agentleFS
kohojkohoj/skills/xiaohongshu-to-markdown/SKILL.md

xiaohongshu-to-markdown

Skill1 starsChanged 7 months agoMITView on GitHub

Xiaohongshu Article to Markdown — Extracts text from Xiaohongshu image-based posts via OCR. Use when the user needs to convert a Xiaohongshu/Little Red Book post into readable Markdown text. The tool downloads all carousel images from a post and uses macOS Vision OCR to extract the text content. Requires a Chromium browser logged into xiaohongshu.com with CDP enabled. macOS only (uses Vision Framework for OCR).

  • Installs packages

The file

Files
SKILL.md

Xiaohongshu Article to Markdown

Extracts authentication from a Chromium browser via CDP, fetches post data via httpx, downloads carousel images, and OCRs them into a clean Markdown file using macOS Vision Framework.

Quick Start

python3 <skill-path>/scripts/xhs_to_markdown.py <xiaohongshu_url> [--output-dir DIR] [--cdp-port PORT]

Arguments:

  • url (required): Xiaohongshu post URL (e.g., https://www.xiaohongshu.com/explore/...)
  • --output-dir: Output directory, defaults to current working directory
  • --cdp-port: CDP debugging port, default 9222

Output file: {title}_{noteId}.md

Prerequisites

  1. macOS (uses Vision Framework for OCR — no Python OCR dependencies needed)
  2. Chromium-based browser (Chrome / Edge / Brave / Arc) installed and logged in to xiaohongshu.com
  3. Python dependencies: pip install playwright httpx && playwright install chromium
  4. Swift (pre-installed on macOS)

Launch browser with CDP:

# Arc
/Applications/Arc.app/Contents/MacOS/Arc --remote-debugging-port=9222
# Chrome
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
# Edge
/Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge --remote-debugging-port=9222
# Brave
/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser --remote-debugging-port=9222

Architecture

URL → CDP(extract cookies) → httpx(fetch HTML) → parse __INITIAL_STATE__ JSON
→ extract HD image URLs → httpx download images → Swift Vision OCR → Markdown
StepMethodNotes
Cookie extractionCDP ctx.cookies()Invisible, no tabs opened
Page fetchhttpx GETWith browser cookies for auth
Data parsing__INITIAL_STATE__ JSONEmbedded in page HTML
Image downloadhttpx concurrentStrips quality compression suffixes
OCRmacOS Vision Framework (Swift).accurate level, zh-Hans + zh-Hant + en
OutputMarkdown fileTitle + meta + OCR text + description

Output Format

# {title}

> Author: {author} | {time} | [Original]({url})

{OCR text from image 1}

{OCR text from image 2}

...

---

{post description, if present}

Lessons Learned

DateLessonAction

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.