目录
GNU Wget2 - 简介
GNU Wget2 是 GNU Wget 的继任者,是一款文件及递归网站下载工具。
它从零开始设计并编写,封装了 libwget,后者提供了 Web 客户端所需的基本功能。
Wget2 支持多线程,并利用多种特性以实现快速操作。
在许多情况下,由于 HTTP2、HTTP 压缩、并行连接以及对 If-Modified-Since HTTP 头的使用,Wget2 的下载速度远快于 Wget1.x。
GNU Wget2 采用 GPLv3+ 许可证。
Libwget 采用 LGPLv3+ 许可证。
特性
以下是一份非详尽的特性列表
- 支持 HTTP/1.1 和 HTTP/2.0 协议
- brotli 解压缩支持 (Accept-Encoding: br)
- zstandard 解压缩支持, RFC8478 (Accept-Encoding: zstd)
- lzip 解压缩支持, (Accept-Encoding: lzip)
- HPKP - HTTP 公钥固定 (RFC7469) 配合持久化数据库
- 纯文本 以及 HTTPS 的 TCP Fast Open
- TLS 会话恢复,包括持久化会话数据缓存
- TLS False Start (需 GnuTLS >= 3.5.0)
- 通过 nghttp2 和 GnuTLS ALPN 支持 HTTP2,包括流式/管道传输
- OCSP 装订 + OCSP 服务器查询作为回退方案 (实验性,需 GnuTLS >= 3.3.11)
- 使用 libpsl 进行 Cookie 域名检查 (使用公共后缀列表)
- 支持链接转换 (-k/--convert-links 和 -K/--backup-converted)
- 支持符合 RFC 6266 的 Content-Disposition
- RFC 6797 HSTS (HTTP 严格传输安全)
- 支持 bzip2 Content-Encoding / Accept-Encoding 压缩类型
- 2014 新年彩蛋:新增对 XZ Content-Encoding / Accept-Encoding 压缩类型的支持
- 尽管存在本地和远程编码,仍可指定输入文件的字符编码 (--input-encoding)
- 支持从本地文件扫描 RSS 2.0 源 (
--force-rss -i <filename>) - 支持扫描 RSS 2.0 源。
- 支持从本地文件扫描 Atom 1.0 源 (
--force-atom -i <filename>) - 支持扫描 Atom 1.0 源。
- 支持从本地 Sitemap XML 文件扫描 URL (
--force-sitemap -i <filename>) - 支持扫描 robots.txt 中指定的站点地图文件 (Sitemap XML、压缩的 Sitemap XML、纯文本),包括
站点地图索引文件。
- 支持任意数量的代理以进行并行下载
- 单文件多线程下载(选项 --chunk-size)
- 应用程序中的国际化域名(可编译选择 IDNA2008 或 IDNA2003)
- 通过库支持 ICEcast / SHOUTcast(参见 examples/getstream.c)
- 遵守 /robots.txt “机器人排除标准” 和
<META name="robots" ...> - 新选项 --secure-protocol=PFS 以仅使用 TLS 并强制完美前向保密(PFS)
- 支持国际域名的 IDN
- autotools 支持
- 代理支持
- Cookie(会话/非会话),通过 Mozilla 公共后缀列表检测超级 Cookie
(使用新选项
--cookie-suffixes <filename>,更好:将其放入 ~/.wgetrc) - 网站的递归下载,可跨主机或不跨主机
- 单个网页 / 资源的下载
- zlib/gzip 压缩的 HTTP/HTTPS 下载(gzip, deflate)
- 并行下载线程数可调整
- 配置文件的 include 指令(允许通配符)
- 支持 keep-alive 连接
- 递归下载所需的 CSS、HTML、XML 解析器
- gettext 支持
- 通过 libgnutls 支持 HTTPS(以及基本的 WolfSSL 支持)
- 支持 Metalink RFC 6249(Metalink/HTTP:镜像和哈希)
- 支持 Metalink RFC 5854(Metalink 下载描述格式 / .meta4 文件)
- 支持 Metalink 3
- 通过 libgnutls 进行 Metalink 校验
- DNS 查找缓存
- IPv4 和 IPv6 支持
- 在 Linux、OSX、OpenBSD、FreeBSD、Solaris、Windows 上构建和测试
链接
构建要求
构建该软件需要以下软件包
- autotools (autoconf, autogen, automake, autopoint, libtool)
- python (推荐用于更快的 bootstrap)
- rsync
- tar
- makeinfo (texinfo 的一部分)
- pkg-config >= 0.28 (推荐)
- doxygen (用于创建文档)
- pandoc (用于创建 wget2 man page)
- gettext >= 0.18.2
- libiconv (IRI 和 IDN 支持所需)
- libz >= 1.2.3 (发行版可能将该包称为 zlib*,例如 Debian 上的 zlib1g)
- liblzma >= 5.1.1alpha (可选,如果需要 HTTP lzma 解压缩)
- libbz2 >= 1.0.6 (可选,如果需要 HTTP bzip2 解压缩)
- libbrotlidec/libbrotli >= 1.0.0 (可选,如果需要 HTTP brotli 解压缩)
- libzstd >= 1.3.0 (可选,如果需要 HTTP zstd 解压缩)
- libgnutls (3.3, 3.5 或 3.6)
- libidn2 >= 0.14 (如果没有 libidn2,则使用 libidn >= 1.25)
- flex >= 2.5.35
- libpsl >= 0.5.0
- libnghttp2 >= 1.3.0 (可选,如果需要 HTTP/2 支持)
- libmicrohttpd >= 0.9.51 (可选,如果需要运行测试套件)
- lzip (可选,如果需要构建发行版 tarball)
- lcov (可选,用于覆盖率报告)
- libgpgme >= 0.4.2 (可选,用于自动签名验证)
- libpcre | libpcre2 (可选,用于通过 PCRE|PCRE2 正则表达式进行过滤)
- libhsts (可选,用于支持 HSTS 预加载列表)
- libwolfssl (可选,用于支持 WolfSSL 而非 GnuTLS)
版本为推荐版本,但旧版本也可能可用。
从 tarball 下载和构建
wget https://gnuwget.gitlab.io/wget2/wget2-latest.tar.gz tar xf wget2-latest.tar.gz cd wget2-* ./configure make make check sudo make install
从 git 构建
使用以下命令下载项目并准备源代码
git clone https://gitlab.com/gnuwget/wget2.git
cd wget2
./bootstrap
# 如果 shell 失败,请尝试 'bash ./bootstrap'
使用以下命令构建 Wget2
./configure
make
在 Haiku 上使用以下命令构建 Wget2
setarch x86
./configure --prefix=/boot/home/config/non-packaged
rm /boot/home/config/non-packaged/wget2 && mv /boot/home/config/non-packaged/wget2_noinstall /boot/home/config/non-packaged/wget2
测试功能
make check
安装 Wget2 和 libwget
sudo make install (或 su -c "make install")
在 GNU/Linux 上为 Windows 构建静态 wget2.exe
(cd contrib; docker build -t wget2/win32/static -f Dockerfile.win32.static .)
docker run --rm -v $PWD:/tmp wget2/win32/static cp /usr/local/wget2/src/wget2.exe /tmp
sudo chown $USER: wget2.exe
# 现在你在当前目录中拥有带调试符号的 `wget2.exe`
# 可选:使用以下命令移除调试符号
# strip wget2.exe # (需要 mingw64 版本的 `strip`)
# 可选:打包可执行文件
upx wget2.exe
在 GNU/Linux 上为 Linux/amd64 构建静态 wget2
(cd contrib; docker build -t wget2/static/amd64 -f Dockerfile.musl.static.amd64 .)
docker run --rm -v $PWD:/tmp wget2/static/amd64 cp /usr/local/wget2/src/wget2 /tmp
sudo chown $USER: wget2
# 现在你在当前目录下拥有了带调试符号的 wget2.exe
# 可选:使用以下命令移除调试符号
strip wget2
# 可选:打包可执行文件
upx wget2
许可证
Copyright (C) 2015-2026 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License can be found in the file LICENSE in the top directory of the official source distribution. The license is also available in several formats through the World Wide Web, or via http://www.gnu.org/licenses/licenses.html#GPL .