Xiaohongshu Video Downloader
Download videos from Xiaohongshu (小红书) by extracting the real CDN URL from the page.
How It Works
Xiaohongshu videos use blob URLs in the browser, which cannot be downloaded directly. This skill:
- 1. Uses browser automation to load the page (required for JS rendering)
- Extracts the real CDN video URL from the page HTML
- Downloads the video with proper headers
Method 1: Browser Automation (Recommended)
Use the browser tool to extract the video URL:
- 1. Navigate to the Xiaohongshu page:
CODEBLOCK0
- 2. Extract the video URL with JavaScript:
CODEBLOCK1
- 3. Download with curl:
CODEBLOCK2
Method 2: Python Script
For pages that don't require authentication:
CODEBLOCK3
Note: The Python script may not work for all pages due to:
- - JavaScript rendering requirements
- Authentication/login requirements
- Rate limiting
Notes
- - Videos are typically hosted on
xhscdn.com CDN - User-Agent and Referer headers are required to avoid 403 errors
- Output directory: INLINECODE1
- Video URLs follow pattern: INLINECODE2
小红书视频下载器
通过从页面提取真实CDN URL来下载小红书视频。
工作原理
小红书视频在浏览器中使用blob URL,无法直接下载。本技能:
- 1. 使用浏览器自动化加载页面(需要JS渲染)
- 从页面HTML中提取真实CDN视频URL
- 使用正确的请求头下载视频
方法一:浏览器自动化(推荐)
使用浏览器工具提取视频URL:
- 1. 导航至小红书页面:
browser action=navigate targetUrl=https://www.xiaohongshu.com/explore/NOTE_ID
- 2. 使用JavaScript提取视频URL:
javascript
(() => {
const html = document.documentElement.outerHTML;
const mp4Matches = html.match(/https?:\/\/[^\s]+\.mp4[^\s]*/g);
if (mp4Matches) return [...new Set(mp4Matches)];
return null;
})()
- 3. 使用curl下载:
bash
curl -L -o output.mp4
\
-H User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10157) AppleWebKit/537.36 \
-H Referer: https://www.xiaohongshu.com/
方法二:Python脚本
适用于无需认证的页面:
bash
python3 scripts/downloadvideo.py https://www.xiaohongshu.com/explore/NOTEID
注意:Python脚本可能不适用于所有页面,原因包括:
- - 需要JavaScript渲染
- 需要认证/登录
- 存在频率限制
注意事项
- - 视频通常托管在xhscdn.com CDN上
- 需要设置User-Agent和Referer请求头以避免403错误
- 输出目录:~/Downloads/xiaohongshu/
- 视频URL遵循格式:https://sns-video-.xhscdn.com/stream/.../.mp4