AgentSkillsCN

xhs

捕捉并归档小红书(Xiaohongshu/RED)上的帖子,包括视频、图片和文字内容。当用户分享 xiaohongshu.com 链接,并希望保存、归档、分析或总结相关内容时,可使用此技能。支持通过 Gemini 进行视频分析(可选)。当用户提及“保存这个 XHS 链接”、“归档这篇小红书帖子”、“分析小红书上的这段视频”,或当用户分享 xiaohongshu.com URL 时,此技能将自动触发。

SKILL.md
--- frontmatter
name: xhs
description: Capture and archive Xiaohongshu (小红书/RED) posts including videos, images, and text. Use when user shares a xiaohongshu.com link and wants to save, archive, analyze, or summarize the content. Supports video analysis via Gemini (optional). Triggers on phrases like "save this XHS link", "archive this xiaohongshu post", "analyze this video from xiaohongshu", or when a xiaohongshu.com URL is shared.

Xiaohongshu (XHS) Capture Skill

Extracts and archives content from Xiaohongshu posts with a "Triple-Level Archive" strategy.

Quick Start

bash
# Working directory:
# Run these commands from a directory where `skills/xhs/` exists (i.e., `ls skills/xhs` works).

# 0. Load Config (Important!)
# Create a .env file with XHS_COOKIE='...' and XHS_OUTPUT_DIR='...'
# then load it:
source skills/xhs/.env

# 1. Extract data from URL
python3 skills/xhs/scripts/xhs_bridge.py "https://www.xiaohongshu.com/explore/..."
# This writes `xhs_last_run.json` to your current working directory.

# 2. Archive (download media + create note)
python3 skills/xhs/scripts/xhs_archive.py xhs_last_run.json

# 3. With video analysis (requires GEMINI_API_KEY)
python3 skills/xhs/scripts/xhs_archive.py xhs_last_run.json --analyze

Environment Variables

VariableRequiredDescription
XHS_COOKIEYesCookie string from logged-in browser session
XHS_OUTPUT_DIRNoBase output directory (default: ./xhs_captures)
XHS_NOTES_DIRNoOverride notes directory (advanced)
XHS_MEDIA_DIRNoOverride media directory (advanced)
GEMINI_API_KEYNoEnables video analysis via Gemini

Workflow

  1. Trigger: User shares xiaohongshu.com link
  2. Extract: Run xhs_bridge.py → outputs xhs_last_run.json
  3. Archive: Run xhs_archive.py → downloads media, creates note
  4. Analyze (optional): If user asks to "analyze the video" and GEMINI_API_KEY is set, append Gemini analysis

Output Structure

code
# Default layout (public-friendly)
{XHS_OUTPUT_DIR}/
├── notes/
│   └── YYYY-MM-DD_Title.md      # Insight note
└── media/
    └── YYYY-MM/
        ├── ..._video.mp4        # Raw video
        ├── ..._img1.jpg         # Images
        └── ..._raw.json         # Full metadata

# Advanced: override with XHS_NOTES_DIR + XHS_MEDIA_DIR

Analysis Modes

ModeTrigger PhraseRequirement
Basic"save this", "archive this"XHS_COOKIE only
Full"analyze this video", "what does this say"XHS_COOKIE + GEMINI_API_KEY

If GEMINI_API_KEY is not set, provide text-based analysis from the description/comments.

Cookie Setup

  1. Log in to xiaohongshu.com in browser
  2. Open DevTools (F12) → Network tab
  3. Refresh page, click any request
  4. Copy the Cookie header value
  5. Set: export XHS_COOKIE="..."