提取小红书帖子内容(文字、图片、视频转录),整理为 Markdown 并保存
npx skills add https://github.com/chenxiachan/xhs-claude-skills --skill xhs
用户希望提取小红书帖子内容。请按以下步骤处理:
~/cookies.json(从 Chrome 导出的小红书 cookies)~/Documents/Obsidian Vault/xhsmlx-community/whisper-large-v3-turbo用户提供的小红书链接: $ARGUMENTS
~/cookies.json 是否存在 copy(JSON.stringify(document.cookie.split('; ').map(c => {
const [name, ...rest] = c.split('=');
return { name, value: rest.join('='), domain: '.xiaohongshu.com', path: '/',
expires: Date.now()/1000 + 86400*30, size: name.length + rest.join('=').length,
httpOnly: false, secure: false, session: false, priority: 'Medium',
sameParty: false, sourceScheme: 'Secure', sourcePort: 443 };
})))
~/cookies.json从 URL 中提取帖子 ID(24 位十六进制字符串)和 xsec_token 参数。
使用 Python 脚本,通过 Cookies 请求帖子页面 HTML,从 window.__INITIAL_STATE__ 解析全部帖子数据:
import json, urllib.request, ssl, re
with open('<Cookies 文件>') as f:
cookies = json.load(f)
cookie_str = '; '.join(f"{c['name']}={c['value']}" for c in cookies)
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
req = urllib.request.Request('<帖子URL>')
req.add_header('Cookie', cookie_str)
req.add_header('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36')
resp = urllib.request.urlopen(req, timeout=15, context=ctx)
html = resp.read().decode('utf-8', errors='ignore')
m = re.search(r'window\.__INITIAL_STATE__\s*=\s*(\{.+?\})\s*</script>', html, re.DOTALL)
raw = m.group(1).replace('undefined', 'null')
data = json.loads(raw)
# 帖子数据在: data['note']['noteDetailMap'][<key>]['note']
# 包含: title, desc, type, time, user, imageList, video, interactInfo, ipLocation
如果请求失败(被重定向到 404/错误页),说明 cookies 过期,提示用户按步骤 0 重新导出。
如果帖子 type 为 video,执行以下子步骤:
从步骤 2 获取的数据中解析视频流:
note['video']['media']['stream'] -> 按 h264 > h265 > av1 优先级取第一个的 masterUrl
curl -L -o /tmp/xhs_{post_id}.mp4 -H "Referer: https://www.xiaohongshu.com/" <视频URL>
ffmpeg -y -i /tmp/xhs_{post_id}.mp4 -vn -acodec pcm_s16le -ar 16000 -ac 1 /tmp/xhs_{post_id}.wav
import mlx_whisper
result = mlx_whisper.transcribe("/tmp/xhs_{post_id}.wav",
path_or_hf_repo="mlx-community/whisper-large-v3-turbo", language="zh", verbose=False)
rm -f /tmp/xhs_{post_id}.mp4 /tmp/xhs_{post_id}.wav
将内容整理为 Markdown 文件,保存到 <Obsidian 保存目录>/{YYYY-MM-DD} {短标题}.md。
{发布日期} {短标题}.md,短标题不超过15个字,是核心洞察的极简概括<Obsidian 保存目录>/img/ 或 <Obsidian 保存目录>/video/写作风格:Peter Thiel 式——直接、反直觉、一句话给判断。笔记是决策工具,不是知识库。用户扫一眼就能决定:深挖还是跳过。
文件结构(无 YAML frontmatter):
# 一句话核心洞察(反直觉的判断,不是描述性标题)
核心论点,2-3句话。直接给出"大多数人觉得X,但其实Y"的判断。
不废话,不铺垫,像 Thiel 在董事会上说话。
**与我的关联:** 一句话。读取用户的 memory(~/.claude/projects/*/memory/ 下的
user 和 project 类型记忆)了解用户背景、研究方向和当前工作,据此说清楚
这个内容跟用户有什么关系。如果 memory 不可用,从通用的个人发展/工具/方法论角度切入。
**值得深挖吗:** 是/否。一句话理由。
> [!tip]- 详情
> 帖子核心内容的结构化整理(折叠状态,点开才看到):
> - 从 desc 和视频转录中提炼,清理 `#xxx[话题]#` 标记
> - 按逻辑结构分节,保留关键数据和结论
> - 图片用 `` 嵌入
> - 视频帖子在此处放整理后的转录内容
> [!info]- 笔记属性
> - **来源**: 小红书 · 作者名
> - **帖子ID**: xxx
> - **链接**: 原始链接
> - **日期**: YYYY-MM-DD
> - **类型**: image/video
> - **互动**: N赞 / N收藏 / N评论
> - **标签**: 标签1, 标签2, ...
关键约束:
urlDefault 字段的 URLCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Improves the quality of images, especially screenshots, by enhancing resolution, sharpness, and clarity. Perfect for preparing images for presentations, documentation, or social media posts.
Downloads videos from YouTube and other platforms for offline viewing, editing, or archival. Handles various formats and quality options.
Lightweight WSI tile extraction and preprocessing. Use for basic slide processing tissue detection, tile extraction, stain normalization for H&E images. Best for simple pipelines, dataset preparation, quick tile-based analysis. For advanced spatial proteomics, multiplexed imaging, or deep learning pipelines use pathml.
Microscopy data management platform. Access images via Python, retrieve datasets, analyze pixels, manage ROIs/annotations, batch processing, for high-content screening and microscopy workflows.
Python library for working with DICOM (Digital Imaging and Communications in Medicine) files. Use this skill when reading, writing, or modifying medical imaging data in DICOM format, extracting pixel data from medical images (CT, MRI, X-ray, ultrasound), anonymizing DICOM files, working with DICOM metadata and tags, converting DICOM images to other formats, handling compressed DICOM data, or processing medical imaging datasets. Applies to tasks involving medical image analysis, PACS systems, radiology workflows, and healthcare imaging applications.
This skill should be used when working with pre-trained transformer models for natural language processing, computer vision, audio, or multimodal tasks. Use for text generation, classification, question answering, translation, summarization, image classification, object detection, speech recognition, and fine-tuning models on custom datasets.
Take chenxiachan/xhs from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.