Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Search, analyze, and interact with Xiaohongshu (RedNote/小红书) content via a local MCP server and shell scripts.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
tools/xhs-downloader/batch_download.py
1#!/usr/bin/env python2"""3批量下载小红书笔记45用法:6python batch_download.py [links_file]78默认读取当前目录的 links.md 文件9"""10import asyncio11import sys12from pathlib import Path1314try:15from source import XHS16except ImportError:17print("错误: 请在 XHS-Downloader 项目目录下运行此脚本")18print("或安装依赖: pip install -e /path/to/XHS-Downloader")19sys.exit(1)202122async def main():23# 读取链接文件24links_file = Path(sys.argv[1]) if len(sys.argv) > 1 else Path("links.md")2526if not links_file.exists():27print(f"错误: 链接文件不存在: {links_file}")28print("用法: python batch_download.py [links_file]")29sys.exit(1)3031links = links_file.read_text().strip()32link_count = len([l for l in links.split() if l.startswith("http")])3334print(f"开始下载,共 {link_count} 个链接...")3536async with XHS(37work_path="./Volume",38folder_name="Download",39record_data=True, # 记录作品数据到数据库40download_record=True, # 跳过已下载41author_archive=True, # 按作者分文件夹42) as xhs:43result = await xhs.extract(links, download=True)44print(f"完成!处理了 {len(result)} 个作品")454647if __name__ == "__main__":48asyncio.run(main())49