发布 2.1 版本

This commit is contained in:
JoeanAmier 2024-06-30 17:37:10 +08:00
parent b87132e364
commit 3d28a6f262
13 changed files with 310 additions and 138 deletions

View File

@ -1,16 +1,16 @@
FROM python:3.12.4-slim
LABEL name="XHS-Downloader" version="2.1 Beta" authors="JoeanAmier"
LABEL name="XHS-Downloader" version="2.1" authors="JoeanAmier"
COPY locale /locale
COPY source /source
COPY static /static
COPY LICENSE /LICENSE
COPY main.py /main.py
COPY README.md /README.md
COPY README_EN.md /README_EN.md
COPY requirements.txt /requirements.txt
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
EXPOSE 8000
CMD ["python", "main.py"]

View File

@ -43,11 +43,11 @@
<p>⭐ XHS-Downloader 开发计划及进度可前往 <a href="https://github.com/users/JoeanAmier/projects/5">Projects</a> 查阅</p>
<h1>📸 程序截图</h1>
<p><b>🎥 点击图片观看演示视频</b></p>
<a href="https://www.bilibili.com/video/BV1PJ4m1Y7Jt/"><img src="static/screenshot/程序运行截图CN1.png" alt=""></a>
<a href="https://www.bilibili.com/video/BV1H6421f7kT/"><img src="static/screenshot/程序运行截图CN1.png" alt=""></a>
<hr>
<a href="https://www.bilibili.com/video/BV1PJ4m1Y7Jt/"><img src="static/screenshot/程序运行截图CN2.png" alt=""></a>
<a href="https://www.bilibili.com/video/BV1H6421f7kT/"><img src="static/screenshot/程序运行截图CN2.png" alt=""></a>
<hr>
<a href="https://www.bilibili.com/video/BV1PJ4m1Y7Jt/"><img src="static/screenshot/程序运行截图CN3.png" alt=""></a>
<a href="https://www.bilibili.com/video/BV1H6421f7kT/"><img src="static/screenshot/程序运行截图CN3.png" alt=""></a>
<h1>🔗 支持链接</h1>
<ul>
<li><code>https://www.xiaohongshu.com/explore/作品ID</code></li>
@ -59,11 +59,25 @@
<h1>🪟 关于终端</h1>
<p>⭐ 推荐使用 <a href="https://learn.microsoft.com/zh-cn/windows/terminal/install">Windows 终端</a> Windows 11 默认终端)运行程序以便获得最佳显示效果!</p>
<h1>🥣 使用方法</h1>
<p>如果仅需下载无水印作品文件,建议选择 <b>程序运行</b>;如果有其他需求,建议选择 <b>源码运行</b></p>
<p>如果仅需下载无水印作品文件,建议选择 <b>程序运行</b><b>Docker 运行</b>;如果有其他需求,建议选择 <b>源码运行</b></p>
<p>建议自行设置 <code>cookie</code> 参数,若不设置该参数,程序功能可能无法正常使用!</p>
<h2>🖱 程序运行</h2>
<p>Windows 10 及以上用户可前往 <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> 下载程序压缩包,解压后打开程序文件夹,双击运行 <code>main.exe</code> 即可使用。</p>
<p>若通过此方式使用程序,文件默认下载路径为:<code>.\_internal\Download</code>;配置文件路径为:<code>.\_internal\settings.json</code></p>
<h2>⌨️ Docker 运行</h2>
<ol>
<li>获取镜像</li>
<ul>
<li>方式一:使用 <code>Dockerfile</code> 文件构建镜像</li>
<li>方式二:使用 <code>docker pull joeanamier/xhs-downloader</code> 命令拉取镜像</li>
</ul>
<li>创建容器</li>
<ul>
<li>TUI 模式:<code>docker run -it joeanamier/xhs-downloader:2.1</code></li>
<li>API 模式:<code>docker run -it joeanamier/xhs-downloader:2.1 python main.py server</code></li>
</ul>
</ol>
<p>Docker 运行项目时不支持 <b>命令行调用模式</b>,无法使用 <b>读取剪贴板</b><b>监听剪贴板</b> 功能,可以正常粘贴内容,其他功能如有异常请反馈!</p>
<h2>⌨️ 源码运行</h2>
<ol>
<li>安装版本号不低于 <code>3.12</code> 的 Python 解释器</li>
@ -383,7 +397,7 @@ async def example():
</ul>
<b>在使用本项目的代码和功能之前,请您认真考虑并接受以上免责声明。如果您对上述声明有任何疑问或不同意,请不要使用本项目的代码和功能。如果您使用了本项目的代码和功能,则视为您已完全理解并接受上述免责声明,并自愿承担使用本项目的一切风险和后果。</b>
# 💡 代码参考
# 💡 项目参考
* https://github.com/encode/httpx/
* https://github.com/tiangolo/fastapi

View File

@ -12,117 +12,217 @@
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/JoeanAmier/XHS-Downloader/total?style=for-the-badge&color=f759ab">
</div>
<br>
<div align="center">
<p>🔥 <b>Xiaohongshu Artwork Collection Tool</b>: Collect information on Xiaohongshu artworks; Extract the download address of Xiaohongshu artworks; Download the Xiaohongshu watermark-free artwork files!</p>
<p>❤️ The author only releases XHS-Downloader on GitHub, without collaborating with any individuals or websites. Additionally, there are no charging plans for the tool!</p>
<p>⭐ Due to the author's limited energy, I was unable to update the English document in a timely manner, and the content may have become outdated. Suggest referring to Chinese documentation. If you want to contribute to translation, we warmly welcome you</p>
</div>
<h1>📑 The Project Features:</h1>
<ul>
<li>Collect Xiaohongshu graphic/text or video artworks' information</li>
<li>Extract Xiaohongshu graphic/text or video artworks' download addresses</li>
<li>Download Xiaohongshu graphic/text or video artworks without watermarks</li>
<li>Supports Tampermonkey user scripts</li>
<li>Batch download account artworks (with user scripts)</li>
<li>Automatically skip already downloaded artworks</li>
<li>Mechanism for handling the integrity of artwork files</li>
<li>Customize the download format for graphic and text artworks</li>
<li>Persistently store artwork information to a file</li>
<li>Store artwork files in a separate folder</li>
<li>☑️ Background monitoring of clipboard for downloading artworks</li>
<li>☑️ Supports API calling functionality</li>
<p>🔥 <b>Xiaohongshu Link Extraction/Content Collection Tool</b>Extract account-published, favorited, and liked content links; extract search result content links and user links; collect Xiaohongshu content information; extract Xiaohongshu content download addresses; download Xiaohongshu watermark-free content files!</p>
<p>⭐ Due to the author's limited energy, I was unable to update the English document in a timely manner, and the content may have become outdated, partial translation is machine translation, the translation result may be incorrect, Suggest referring to Chinese documentation. If you want to contribute to translation, we warmly welcome you.</p>
<h1>📑 Project Features</h1>
<ul><b>Program Features</b>
<li>✅ Collect Xiaohongshu content information</li>
<li>✅ Extract Xiaohongshu content download addresses</li>
<li>✅ Download Xiaohongshu watermark-free content files</li>
<li>Download Xiaohongshu livePhoto files (non-watermark-free)</li>
<li>Automatically skip already downloaded content files</li>
<li>Content file integrity handling mechanism</li>
<li>Customizable text and image content file download format</li>
<li>Persistently store content information to files</li>
<li>Store content files to a separate folder</li>
<li>Background clipboard monitoring for content download</li>
<li>Record downloaded content IDs</li>
<li>Support command line for downloading content files</li>
<li>Read cookies from browser</li>
<li>✅ Customizable file name format</li>
<li>✅ Support API call functionality</li>
</ul>
<h1>📸 Program Screenshot</h1>
<br>
<p><b>🎥 Click on the image to watch the demo video</b></p>
<a href="https://www.bilibili.com/video/BV1nQ4y137it/"><img src="static/screenshot/程序运行截图EN1.png" alt=""></a>
<ul><b>Script Features</b>
<li>✅ Download Xiaohongshu watermark-free content files</li>
<li>✅ Extract discovery page content links</li>
<li>✅ Extract account-published content links</li>
<li>✅ Extract account-favorited content links</li>
<li>✅ Extract account-liked content links</li>
<li>✅ Extract search result content links</li>
<li>✅ Extract search result user links</li>
</ul>
<p>⭐ The development plan and progress of XHS-Downloader can be found at <a href="https://github.com/users/JoeanAmier/projects/5">Projects</a></p>
<h1>📸 Program Screenshots</h1>
<p><b>🎥 Click the images to watch the demo video</b></p>
<a href="https://www.bilibili.com/video/BV1H6421f7kT/"><img src="static/screenshot/程序运行截图EN1.png" alt=""></a>
<hr>
<a href="https://www.bilibili.com/video/BV1nQ4y137it/"><img src="static/screenshot/程序运行截图EN2.png" alt=""></a>
<h1>🔗 Support Hyperlinks</h1>
<a href="https://www.bilibili.com/video/BV1H6421f7kT/"><img src="static/screenshot/程序运行截图EN2.png" alt=""></a>
<hr>
<a href="https://www.bilibili.com/video/BV1H6421f7kT/"><img src="static/screenshot/程序运行截图EN3.png" alt=""></a>
<h1>🔗 Supported Links</h1>
<ul>
<li><code>https://www.xiaohongshu.com/explore/artwork's ID</code></li>
<li><code>https://www.xiaohongshu.com/discovery/item/artwork's ID</code></li>
<li><code>https://xhslink.com/share code</code></li>
<li><code>https://www.xiaohongshu.com/explore/WorksID</code></li>
<li><code>https://www.xiaohongshu.com/discovery/item/WorksID</code></li>
<li><code>https://xhslink.com/ShareCode</code></li>
<br/>
<p><b>The program supports entering multiple artwork links in a single input box, separated by spaces.</b></p>
<p><b>Supports entering multiple content links at once, separated by spaces; the program will automatically extract valid links without additional processing!</b></p>
</ul>
<h1>🪟 About the Terminal</h1>
<p><a href="https://learn.microsoft.com/zh-cn/windows/terminal/install">Windows Terminal</a> (Default terminal in Windows 11) is recommended to run the program for optimal display performance!</p>
<h1>🥣 How to Use</h1>
<p>If you only need to download watermark-free artwork files, <b>Program Running</b> is recommended; If you have other needs, <b>Source Code Running</b> is recommended!</p>
<h2>🖱 Program Running</h2>
<p>Users with Windows 10 or above can go to <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> download the program zip file, unzip it, open the program folder, and double-click <code>main.exe</code> to run the program</p>
<p>If you use the program this way, the default download path for files is: <code>.\_internal\Download</code>; configuration file path: <code>.\_internal\settings.json</code></p>
<h2>⌨️ Source Code Running</h2>
<p>⭐ It is recommended to use the <a href="https://learn.microsoft.com/en-us/windows/terminal/install">Windows Terminal</a> (default terminal for Windows 11) to run the program for the best display effect!</p>
<h1>🥣 Usage</h1>
<p>If you only need to download watermark-free content files, it is recommended to choose <b>Program Run</b>; if you have other needs, it is recommended to choose <b>Source Code Run</b>!</p>
<p>It is recommended to set the <code>cookie</code> parameter manually; if this parameter is not set, the program functions may not work properly!</p>
<h2>🖱 Program Run</h2>
<p>Windows 10 and above users can go to <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> to download the program package, unzip it, open the program folder, and double-click to run <code>main.exe</code> to use.</p>
<p>If you use the program in this way, the default download path for files is: <code>.\_internal\Download</code>; the configuration file path is: <code>.\_internal\settings.json</code></p>
<h2>⌨️ Docker Run</h2>
<ol>
<li>Install Python Interpreter with version >= <code>3.12</code></li>
<li>Execute <code>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt</code> to install the required modules for the program</li>
<li>Download the latest source code or code released in <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> to your local workplace</li>
<li>Run <code>main.py</code> to use the program</li>
</ol>
<h1>🕹 User Script</h1>
<p>If your browser has installed <a href="https://www.tampermonkey.net/">Tampermonkey</a> extension, add <a href="https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/master/static/XHS-Downloader.js">User script</a>, and you can experience the project's functionalities without downloading the program!</p>
<p>Tip: You can use the XHS-Downloader user script to extract artwork links in batches from web pages. Combine it with the XHS-Downloader program to achieve batch downloading of watermark-free artwork files!</p>
<h2>Script Functionality</h2>
<li>Get Image</li>
<ul>
<li>Download Xiaohongshu watermark-free artwork files</li>
<li>Extract artwork links from the discovery page</li>
<li>Extract artwork links from account-published content</li>
<li>Extract artwork links from account-collected content</li>
<li>Extract artwork links from account-liked content</li>
<li>Method 1: Build the image using the <code>Dockerfile</code></li>
<li>Method 2: Pull the image using the command <code>docker pull joeanamier/xhs-downloader</code></li>
</ul>
<h2>Script Screenshot</h2>
<img src="static/screenshot/用户脚本截图1.png" alt="">
<li>Create Container</li>
<ul>
<li>TUI Mode: <code>docker run -it joeanamier/xhs-downloader:2.1</code></li>
<li>API Mode: <code>docker run -it joeanamier/xhs-downloader:2.1 python main.py server</code></li>
</ul>
</ol>
<p>When running the project via Docker, the <b>command line call mode</b> is not supported. The <b>clipboard reading</b> and <b>clipboard monitoring</b> functions are unavailable, but pasting content works fine. Please provide feedback if other features are not functioning properly!</p>
<h2>⌨️ Source Code Run</h2>
<ol>
<li>Install the Python interpreter with a version no lower than <code>3.12</code></li>
<li>Run the command <code>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt</code> to install the required modules</li>
<li>Download the latest source code of this project or the source code released in <a href="https://github.com/JoeanAmier/XHS-Downloader/releases/latest">Releases</a> to your local machine</li>
<li>Run <code>main.py</code> to use</li>
</ol>
<h1>🛠 Command Line Mode</h1>
<p>The project supports command line mode. If you want to download specific images from a text and image work, you can use this mode to set the image sequence number you want to download!</p>
<p>You can use the command line to <b>read cookies from the browser and write to the configuration file</b>! Note that you need to close the browser to read the data!</p>
<p>Command example: <code>python .\main.py --browser_cookie Chrome --update_settings</code></p>
<p>The <code>bool</code> type parameters support setting with <code>true</code>, <code>false</code>, <code>1</code>, <code>0</code>, <code>yes</code>, <code>no</code>, <code>on</code> or <code>off</code> (case insensitive).</p>
<hr>
<img src="static/screenshot/用户脚本截图2.png" alt="">
<h1>💻 Secondary Development</h1>
<p>If there are other requirements, you can call or modify the program refer to the comments in <code>main.py</code></p>
<pre>
# Example links
error_link = "https://github.com/JoeanAmier/XHS_Downloader"
demo_link = "https://www.xiaohongshu.com/explore/xxxxxxxxxx"
multiple_links = f"{demo_link} {demo_link} {demo_link}"
# Instance object
work_path = "D:\\" # Artwork data/file save root path, default value: project root path
folder_name = "Download" # Artwork file storage folder name (automatically created), default value: Download
user_agent = "" # Request Header: User-Agent
cookie = "" # Xiaohongshu web version Cookie, no need to log in
proxy = None # Network proxy
timeout = 5 # Request data timeout limit, unit: seconds, default value: 10
chunk = 1024 * 1024 * 10 # When downloading files, the size of each data block obtained from the server each time, unit: bytes
max_retry = 2 # Maximum number of retries when requesting data fails, unit: seconds, default value: 5
record_data = False # Whether to record artwork data to a file
image_format = "WEBP" # Graphic artwork file download format, supports: PNG, WEBP
folder_mode = False # Whether to store each artwork's file in a separate folder
async with XHS() as xhs:
pass # Use default parameters
async with XHS(work_path=work_path,
folder_name=folder_name,
user_agent=user_agent,
cookie=cookie,
proxy=proxy,
timeout=timeout,
chunk=chunk,
max_retry=max_retry,
record_data=record_data,
image_format=image_format,
folder_mode=folder_mode,
) as xhs: # Use custom parameters
download = True # Whether to download artwork files, default value: False
# Return detailed information about the artwork, including download addresses
print(await xhs.extract(error_link, download)) # Return an empty dictionary when data retrieval fails
print(await xhs.extract(demo_link, download))
print(await xhs.extract(multiple_links, download)) # Support input of multiple artwork links
</pre>
<h1>⚙️ Configuration File</h1>
<p><code>settings.json</code> in the project's root directory, generated automatically on the first run, and allows customization of certain runtime parameters</p>
<p>If your computer doesn't have a suitable program to edit JSON files, it is recommended to use <a href="https://try8.cn/tool/format/json">JSON Online Tool</a> to edit the content of the configuration file</p>
<img src="static/screenshot/命令行模式截图1.png" alt="">
<hr>
<img src="static/screenshot/命令行模式截图2.png" alt="">
<h1>🖥 Server Mode</h1>
<p><b>Start:</b> Run the command: <code>python .\main.py server</code></p>
<p><b>Stop:</b> Press <code>Ctrl</code> + <code>C</code> to stop the server</p>
<p><b>Request endpoint:</b>
<code>/xhs/</code></p>
<p><b>Request method:</b>
<code>POST</code></p>
<p><b>Request format:</b>
<code>JSON</code></p>
<p><b>Request parameters:</b></p>
<table>
<thead>
<tr>
<th align="center">Parameters</th>
<th align="center">Parameter</th>
<th align="center">Type</th>
<th align="center">Meaning</th>
<th align="center">Description</th>
<th align="center">Default</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">url</td>
<td align="center">str</td>
<td align="center">Xiaohongshu content link, auto-extraction, does not support multiple links</td>
<td align="center">None</td>
</tr>
<tr>
<td align="center">download</td>
<td align="center">bool</td>
<td align="center">Whether to download the content file; set to <code>true</code> will take more time</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">index</td>
<td align="center">list[int]</td>
<td align="center">Download specific image files by index, only effective for text and image works; not effective when the <code>download</code> parameter is set to <code>false</code></td>
<td align="center">null</td>
</tr>
<tr>
<td align="center">skip</td>
<td align="center">bool</td>
<td align="center">Whether to skip content with download records; set to <code>true</code> will not return content data with download records</td>
<td align="center">false</td>
</tr>
</tbody>
</table>
<p><b>Code example:</b></p>
<pre>
def api_demo():
server = "http://127.0.0.1:8000/xhs/"
data = {
"url": "https://www.xiaohongshu.com/explore/123456789",
"download": True,
"index": [
3,
6,
9,
],
}
response = requests.post(server, json=data)
print(response.json())
</pre>
<h1>🕹 User Script</h1>
<p>If your browser has the <a href="https://www.tampermonkey.net/">Tampermonkey</a> browser extension installed, you can add the <a href="https://raw.githubusercontent.com/JoeanAmier/XHS-Downloader/master/static/XHS-Downloader.js">user script</a> to experience the project features without needing to download or install anything!</p>
<img src="static/screenshot/脚本安装教程.png" alt="">
<p>After successfully installing the script, open the Xiaohongshu page, check the script instructions, and follow the prompts to operate.</p>
<img src="static/screenshot/用户脚本截图1.png" alt="">
<hr>
<img src="static/screenshot/用户脚本截图2.png" alt="">
<p>Note: Using the XHS-Downloader user script to batch extract content links, in combination with the XHS-Downloader program, can achieve batch downloading of watermark-free content files!</p>
<h1>💻 Secondary Development</h1>
<p>If you have other needs, you can perform code calls or modifications based on the comments in <code>main.py</code>!</p>
<pre>
async def example():
"""通过代码设置参数,适合二次开发"""
# 示例链接
error_link = "https://github.com/JoeanAmier/XHS_Downloader"
demo_link = "https://www.xiaohongshu.com/explore/xxxxxxxxxx"
multiple_links = f"{demo_link} {demo_link} {demo_link}"
# 实例对象
work_path = "D:\\" # 作品数据/文件保存根路径,默认值:项目根路径
folder_name = "Download" # 作品文件储存文件夹名称自动创建默认值Download
name_format = "作品标题 作品描述"
sec_ch_ua = "" # 请求头 Sec-Ch-Ua
sec_ch_ua_platform = "" # 请求头 Sec-Ch-Ua-Platform
user_agent = "" # User-Agent
cookie = "" # 小红书网页版 Cookie无需登录必需参数登录状态对数据采集有影响
proxy = None # 网络代理
timeout = 5 # 请求数据超时限制单位默认值10
chunk = 1024 * 1024 * 10 # 下载文件时,每次从服务器获取的数据块大小,单位:字节
max_retry = 2 # 请求数据失败时重试的最大次数单位默认值5
record_data = False # 是否保存作品数据至文件
image_format = "WEBP" # 图文作品文件下载格式支持PNG、WEBP
folder_mode = False # 是否将每个作品的文件储存至单独的文件夹
async with XHS() as xhs:
pass # 使用默认参数
async with XHS(work_path=work_path,
folder_name=folder_name,
name_format=name_format,
sec_ch_ua=sec_ch_ua,
sec_ch_ua_platform=sec_ch_ua_platform,
user_agent=user_agent,
cookie=cookie,
proxy=proxy,
timeout=timeout,
chunk=chunk,
max_retry=max_retry,
record_data=record_data,
image_format=image_format,
folder_mode=folder_mode,
) as xhs: # 使用自定义参数
download = True # 是否下载作品文件默认值False
# 返回作品详细信息,包括下载地址
# 获取数据失败时返回空字典
print(await xhs.extract(error_link, download, ))
print(await xhs.extract(demo_link, download, ))
# 支持传入多个作品链接
print(await xhs.extract(multiple_links, download, ))
</pre>
<h1>⚙️ Configuration File</h1>
<p>The <code>settings.json</code> file in the root directory of the project is automatically generated on the first run and allows customization of some runtime parameters.</p>
<p>If invalid parameter values are set, the program will use the default values!</p>
<table>
<thead>
<tr>
<th align="center">Parameter</th>
<th align="center">Type</th>
<th align="center">Description</th>
<th align="center">Default Value</th>
</tr>
</thead>
@ -130,94 +230,139 @@ async with XHS(work_path=work_path,
<tr>
<td align="center">work_path</td>
<td align="center">str</td>
<td align="center">Artwork data/file save root path</td>
<td align="center">Root path for saving content data/files</td>
<td align="center">Project root path</td>
</tr>
<tr>
<td align="center">folder_name</td>
<td align="center">str</td>
<td align="center">Artwork file storage folder name</td>
<td align="center">Name of the folder for storing content files</td>
<td align="center">Download</td>
</tr>
<tr>
<td align="center">name_format</td>
<td align="center">str</td>
<td align="center">Format for content file names. Separate fields with spaces. Supported fields: <code>collects</code>, <code>comments</code>, <code>shares</code>, <code>likes</code>, <code>tags</code>, <code>ID</code>, <code>title</code>, <code>description</code>, <code>type</code>, <code>publish_time</code>, <code>last_update_time</code>, <code>author_nickname</code>, <code>author_id</code></td>
<td align="center"><code>publish_time author_nickname title</code></td>
</tr>
<tr>
<td align="center">sec_ch_ua</td>
<td align="center">str</td>
<td align="center">Browser request header Sec-Ch-Ua</td>
<td align="center">Built-in Chrome Sec-Ch-Ua</td>
</tr>
<tr>
<td align="center">sec_ch_ua_platform</td>
<td align="center">str</td>
<td align="center">Browser request header Sec-Ch-Ua-Platform</td>
<td align="center">Built-in Chrome Sec-Ch-Ua-Platform</td>
</tr>
<tr>
<td align="center">user_agent</td>
<td align="center">str</td>
<td align="center">Request Header: User-Agent</td>
<td align="center">Default UA</td>
<td align="center">Browser User Agent</td>
<td align="center">Built-in Chrome User Agent</td>
</tr>
<tr>
<td align="center">cookie</td>
<td align="center">str</td>
<td align="center">Xiaohongshu web version Cookie<b>No need to log in, modification recommended</b></td>
<td align="center">Default Cookie</td>
<td align="center">Xiaohongshu web version cookie, <b>login not required</b></td>
<td align="center">None</td>
</tr>
<tr>
<td align="center">proxy</td>
<td align="center">str</td>
<td align="center">str|dict</td>
<td align="center">Set program proxy</td>
<td align="center">null</td>
</tr>
<tr>
<td align="center">timeout</td>
<td align="center">int</td>
<td align="center">Request data timeout limit, unit: seconds</td>
<td align="center">Request data timeout limit, in seconds</td>
<td align="center">10</td>
</tr>
<tr>
<td align="center">chunk</td>
<td align="center">int</td>
<td align="center">Size of each data block obtained from the server when downloading files, unit: bytes</td>
<td align="center">Size of data chunk to fetch from the server each time when downloading files, in bytes</td>
<td align="center">1048576(1 MB)</td>
</tr>
<tr>
<td align="center">max_retry</td>
<td align="center">int</td>
<td align="center">Maximum number of retries when requesting data fails, unit: seconds</td>
<td align="center">Maximum number of retries when requesting data fails</td>
<td align="center">5</td>
</tr>
<tr>
<td align="center">record_data</td>
<td align="center">bool</td>
<td align="center">Whether to record artwork data to <code>TXT</code> file</td>
<td align="center">Whether to save content data to a file, saved in <code>SQLite</code> format</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">image_format</td>
<td align="center">str</td>
<td align="center">Graphic and text artwork file download format, support: <code>PNG</code><code>WEBP</code></td>
<td align="center">Download format for text and image content files, supported formats: <code>PNG</code>, <code>WEBP</code></td>
<td align="center">PNG</td>
</tr>
<tr>
<td align="center">image_download</td>
<td align="center">bool</td>
<td align="center">Switch for downloading text and image content files</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">video_download</td>
<td align="center">bool</td>
<td align="center">Switch for downloading video content files</td>
<td align="center">true</td>
</tr>
<tr>
<td align="center">live_download</td>
<td align="center">bool</td>
<td align="center">Switch for downloading animated image files</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">folder_mode</td>
<td align="center">bool</td>
<td align="center">Whether to store each artwork's file in a separate folder; folder names are consistent with file names</td>
<td align="center">Whether to store each content's files in a separate folder; the folder name matches the file name</td>
<td align="center">false</td>
</tr>
<tr>
<td align="center">language</td>
<td align="center">str</td>
<td align="center">Set programming language, currently support: <code>zh_CN</code>, <code>en_GB</code></td>
<td align="center">Set program language. Currently supported: <code>zh_CN</code>, <code>en_GB</code></td>
<td align="center">zh_CN</td>
</tr>
</tbody>
</table>
<p><b>Additional Notes: The parameters <code>sec_ch_ua</code>, <code>sec_ch_ua_platform</code>, and <code>user_agent</code> examples are provided for reference, and need to be set manually only if the program fails to fetch data!</b></p>
<img src="static/screenshot/请求头示例图.png" alt="">
<h1>🌐 Cookie</h1>
<ol>
<li>Open the browser (optional in incognito mode), visit any page on Xiaohongshu</li>
<li>Press <code>F12</code> to open developer tools</li>
<li>Click the <code>Console</code></li>
<li>Input <code>document.cookie</code> then press Enter to confirm</li>
<li>The output content is the Cookie</li>
<li>Open the browser (optional: start in incognito mode) and visit <code>https://www.xiaohongshu.com/explore</code></li>
<li>Log in to your Xiaohongshu account (can be skipped)</li>
<li>Press <code>F12</code> to open the developer tools</li>
<li>Select the <code>Network</code> tab</li>
<li>Check <code>Preserve log</code></li>
<li>In the <code>Filter</code> input box, enter <code>cookie-name:web_session</code></li>
<li>Select the <code>Fetch/XHR</code> filter</li>
<li>Click on any piece of content on the Xiaohongshu page</li>
<li>In the <code>Network</code> tab, select any data packet (if no packets appear, repeat step 7)</li>
<li>Copy and paste the entire Cookie into the program or configuration file</li>
</ol>
<br>
<img src="static/screenshot/获取Cookie示意图.png" alt="">
<h1>🗳 Download Records</h1>
<p>XHS-Downloader will store the IDs of downloaded content in a database. When downloading the same content again, XHS-Downloader will automatically skip the file download (even if the content file does not exist). If you want to re-download the content file, please delete the corresponding content ID from the database and then use XHS-Downloader to download the content file again!</p>
<h1>♥️ Support the Project</h1>
<p>If <b>XHS-Downloader</b> is helpful, please consider giving it a <b>Star</b> ⭐, thank you for your support!</p>
<p>If <b>XHS-Downloader</b> has been helpful to you, please consider giving it a <b>Star</b>. Thank you for your support!</p>
<table>
<thead>
<tr>
<th align="center">WeChat</th>
<th align="center">Alipay</th>
<th align="center">微信(WeChat)</th>
<th align="center">支付宝(Alipay)</th>
</tr>
</thead>
<tbody><tr>
@ -226,17 +371,17 @@ async with XHS(work_path=work_path,
</tr>
</tbody>
</table>
<p>If you wish, consider funding additional support for the <b>XHS-Downloader</b>!</p>
<h1>✉️ Contact us</h1>
<p>If you are willing, you may consider making a donation to provide additional support for <b>XHS-Downloader</b>!</p>
<h1>✉️ Contact the Author</h1>
<ul>
<li>QQ: 2437596031 (please inform intent)</li>
<li>QQ Group: <a href="https://github.com/JoeanAmier/XHS-Downloader/blob/master/static/QQ%E7%BE%A4%E8%81%8A%E4%BA%8C%E7%BB%B4%E7%A0%81.png">Click to obtain the group QR code</a></li>
<li>Email: yonglelolu@gmail.com</li>
<li>Author's WeChat: Downloader_Tools</li>
<li><b>Discord Community</b>: <a href="https://discord.com/invite/ZYtmgKud9Y">Click to Join the Community</a></li>
</ul>
<p><b>Other Open Source Projects by the Author:</b></p>
<ul>
<li><b>TikTokDownloader抖音 / TikTok</b><a href="https://github.com/JoeanAmier/TikTokDownloader">https://github.com/JoeanAmier/TikTokDownloader</a></li>
<li><b>KS-Downloader快手</b><a href="https://github.com/JoeanAmier/KS-Downloader">https://github.com/JoeanAmier/KS-Downloader</a></li>
</ul>
<p>
<b>If you contact me via email, I may not be able to check and respond promptly. I will do my best to reply to your email within seven days. If there are urgent matters or you need a faster response, please contact me through other means. Thank you for your understanding!</b>
</p>
<p><b>If you're interested in DouYin / TikTok, you can check out my other open-source project <a href="https://github.com/JoeanAmier/TikTokDownloader">TikTokDownloader</a></b></p>
<h1>⚠️ Disclaimer</h1>
<ul>
<li>Users decide on their own how to use this project and bear the risks themselves. The author is not responsible for any losses, liabilities, or risks incurred by users in the use of this project</li>
@ -252,3 +397,13 @@ async with XHS(work_path=work_path,
<li>Any secondary development, modification, or compilation of the program based on this project is unrelated to the original author. The original author is not responsible for any consequences related to secondary development or its results. Users should take full responsibility for any situations that may arise from secondary development on their own.</li>
</ul>
<b>Before using the code and functionalities of this project, please carefully consider and accept the above disclaimer. If you have any questions or disagree with the statement, please do not use the code and functionalities of this project. If you use the code and functionalities of this project, it is considered that you fully understand and accept the above disclaimer, and willingly assume all risks and consequences associated with the use of this project.</b>
# 💡 Project References
* https://github.com/encode/httpx/
* https://github.com/tiangolo/fastapi
* https://github.com/textualize/textual/
* https://textual.textualize.io/
* https://aiosqlite.omnilib.dev/en/stable/
* https://click.palletsprojects.com/en/8.1.x/
* https://github.com/borisbabic/browser_cookie3

View File

@ -1,4 +1,4 @@
textual>=0.70.0
textual<=0.63.0
pyperclip>=1.9.0
lxml>=5.2.2
PyYAML>=6.0.1

View File

@ -117,6 +117,7 @@ class CLI:
table.add_column("type", no_wrap=True, style="bold")
table.add_column("description", no_wrap=True, )
# TODO: 语言设置未生效
options = (
("--url", "-u", "str", _("小红书作品链接")),
("--index", "-i", "str", _("下载指定序号的图片文件,仅对图文作品生效;多个序号输入示例:\"1 3 5 7\"")),

View File

@ -92,12 +92,14 @@ class Manager:
"Referer": "https://www.xiaohongshu.com/explore", },
timeout=timeout,
verify=False,
follow_redirects=True,
**self.proxy,
)
self.download_client = AsyncClient(
headers=self.blank_headers,
timeout=timeout,
verify=False,
follow_redirects=True,
**self.proxy,
)
self.image_download = self.check_bool(image_download, True)

View File

@ -25,7 +25,7 @@ __all__ = [
VERSION_MAJOR = 2
VERSION_MINOR = 1
VERSION_BETA = True
VERSION_BETA = False
ROOT = Path(__file__).resolve().parent.parent.parent
PROJECT = f"XHS-Downloader V{VERSION_MAJOR}.{
VERSION_MINOR}{" Beta" if VERSION_BETA else ""}"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 100 KiB