# rget **Repository Path**: daisylan/rget ## Basic Information - **Project Name**: rget - **Description**: rget: 一个使用 Rust 编写的类似 wget 的命令行下载工具。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-28 - **Last Updated**: 2025-12-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # rget 一个使用 Rust 编写的类似 wget 的命令行下载工具。 ## 功能特性 rget 实现了 wget 的主要功能,包括: ### 核心下载功能 - ✅ HTTP/HTTPS 下载 - ✅ 断点续传 (`-c, --continue`) - ✅ 进度显示 - ✅ 限速下载 (`--limit-rate`) - ✅ 重试机制 (`-t, --tries`) - ✅ 超时设置 (`-T, --timeout`) - ✅ 文件完整性自动检测(已完整下载的文件会自动跳过) ### 多线程下载(类似 aria2) - ✅ **单文件分片多线程下载** (`--threads`) - 将大文件分成多个片段并行下载 - ✅ **多个URL并行下载** - 同时下载多个文件 - ✅ 可配置线程数(默认:4个线程) - ✅ 可配置最小分片大小(默认:1MB) ### 网络功能 - ✅ 用户代理设置 (`-U, --user-agent`) - ✅ HTTP 认证 (`--http-user`, `--http-password`) - ✅ 代理支持 (`--proxy`) - ✅ 遵循 HTTP 重定向 ### 输出选项 - ✅ 输出到文件或标准输出 (`-O`) - ✅ 不覆盖已存在文件 (`-n, --no-clobber`) - ✅ 安静模式 (`-q, --quiet`) - ✅ 详细输出 (`-v, --verbose`) - ✅ 调试输出 (`-d, --debug`) ### 高级功能 - ✅ 递归下载 (`-r, --recursive`) - ✅ 目录前缀 (`-P, --directory-prefix`) - ✅ 后台下载 (`-b, --background`) ## 安装 ### 从源码构建 ```bash git clone cd rget cargo build --release ``` 编译后的二进制文件位于 `target/release/rget`。 ### 使用 Cargo 安装 ```bash cargo install --path . ``` ## 使用方法 ### 基本用法 ```bash # 下载文件 rget https://example.com/file.zip # 指定输出文件名 rget -O output.zip https://example.com/file.zip # 下载到指定目录 rget -P /path/to/download https://example.com/file.zip ``` ### 断点续传 ```bash # 继续下载已中断的文件 rget -c https://example.com/large-file.zip # 如果文件已完整下载,会自动检测并跳过 rget -c https://example.com/large-file.zip # 不会重复下载 ``` ### 限速下载 ```bash # 限制下载速度为 1MB/s rget --limit-rate=1M https://example.com/file.zip # 限制下载速度为 500KB/s rget --limit-rate=500K https://example.com/file.zip ``` ### 重试和超时 ```bash # 设置重试次数为 5 次 rget -t 5 https://example.com/file.zip # 设置超时时间为 60 秒 rget -T 60 https://example.com/file.zip ``` ### 用户代理和认证 ```bash # 设置自定义用户代理 rget -U "Mozilla/5.0" https://example.com/file.zip # 使用 HTTP 基本认证 rget --http-user=username --http-password=password https://example.com/file.zip ``` ### 代理支持 ```bash # 使用代理 rget --proxy=http://proxy.example.com:8080 https://example.com/file.zip # 不使用代理 rget --no-proxy https://example.com/file.zip ``` ### 输出选项 ```bash # 输出到标准输出 rget -O - https://example.com/file.zip > output.zip # 不覆盖已存在的文件 rget -n https://example.com/file.zip # 安静模式(不显示进度) rget -q https://example.com/file.zip # 详细输出 rget -v https://example.com/file.zip ``` ### 多线程下载 ```bash # 使用 8 个线程下载大文件(自动分片) rget --threads 8 https://example.com/large-file.zip # 自定义最小分片大小(2MB) rget --threads 16 --min-split-size 2097152 https://example.com/huge-file.zip # 并行下载多个文件 rget https://example.com/file1.zip https://example.com/file2.zip https://example.com/file3.zip ``` ### 递归下载 ```bash # 递归下载网站 rget -r https://example.com/ # 设置递归深度 rget -r -l 3 https://example.com/ ``` ## 命令行参数 ### 基本选项 - `URL` - 要下载的 URL(必需,可指定多个) - `-O, --output-document ` - 输出文件名 - `-P, --directory-prefix ` - 输出目录(默认:当前目录) - `-c, --continue` - 继续下载已存在的文件 - `-n, --no-clobber` - 不覆盖已存在的文件 ### 下载选项 - `-t, --tries ` - 重试次数(默认:20) - `-T, --timeout ` - 超时时间,秒(默认:30) - `--limit-rate ` - 限制下载速度(如:1M, 500K) - `--threads ` - 下载线程数,用于分片下载和并行下载(默认:4) - `--min-split-size ` - 最小分片大小,单位:字节(默认:1048576,即1MB) - `-r, --recursive` - 递归下载 - `-l, --level ` - 递归深度(默认:5) ### 输出选项 - `-q, --quiet` - 安静模式 - `-v, --verbose` - 详细输出 - `-d, --debug` - 调试输出 - `--no-progress-bar` - 不显示进度条 - `--show-progress` - 显示进度 ### 网络选项 - `-U, --user-agent ` - 用户代理字符串 - `--http-user ` - HTTP 用户名 - `--http-password ` - HTTP 密码 - `--proxy ` - 使用代理 - `--no-proxy` - 不使用代理 - `--no-check-certificate` - 不检查 SSL 证书 - `--no-check-hostname` - 不检查主机名 - `--follow-redirects` - 遵循重定向(默认:true) - `--max-redirect ` - 最大重定向次数(默认:20) ### 其他选项 - `-w, --wait ` - 等待时间(秒) - `--random-wait` - 随机等待时间 - `-A, --accept ` - 接受的文件扩展名 - `-R, --reject ` - 拒绝的文件扩展名 - `-I, --include-directories ` - 包含的目录 - `-X, --exclude-directories ` - 排除的目录 ## 示例 ```bash # 下载文件并显示进度 rget https://example.com/large-file.zip # 使用多线程下载大文件(自动分片) rget --threads 8 https://example.com/large-file.zip # 并行下载多个文件 rget https://example.com/file1.zip https://example.com/file2.zip https://example.com/file3.zip # 断点续传(如果文件已完整,会自动跳过) rget -c https://example.com/large-file.zip # 后台下载 rget -b https://example.com/file.zip # 镜像整个网站 rget -m -k -p https://example.com/ # 下载特定类型的文件 rget -r -A "pdf,doc,docx" https://example.com/ # 排除特定目录 rget -r -X "images,css" https://example.com/ ``` ## 与 wget 的兼容性 rget 实现了 wget 的大部分常用功能,并添加了多线程下载等增强功能。但某些高级功能(如 FTP 下载、cookie 管理、时间戳等)可能尚未完全实现。如果您需要这些功能,请考虑使用原始的 wget 工具。 ## 多线程下载说明 rget 支持类似 aria2 的多线程下载功能: 1. **自动分片下载**:当文件大小 >= `min_split_size * threads` 时,自动使用多线程分片下载 2. **智能选择**:小文件自动使用单线程下载,大文件自动使用多线程下载 3. **并行下载**:提供多个 URL 时,自动并行下载所有文件 4. **文件完整性检测**:使用 `-c` 选项时,如果文件已完整下载,会自动跳过 ### 多线程下载示例 ```bash # 下载 100MB 文件,使用 8 个线程(每个线程约 12.5MB) rget --threads 8 https://example.com/100mb-file.zip # 下载多个文件,每个文件使用 4 个线程(默认) rget --threads 4 https://example.com/file1.zip https://example.com/file2.zip # 自定义分片大小:只有大于 5MB 的文件才使用多线程 rget --threads 8 --min-split-size 5242880 https://example.com/file.zip ``` ## 许可证 MIT OR Apache-2.0 ## 贡献 欢迎提交 Issue 和 Pull Request! ## 作者 使用 Rust 语言开发,旨在提供一个快速、安全、功能完整的 wget 替代品。