Ubuntu wget 1.7.1 命令详解


wget 是支持 HTTP FTP 的单线程文件递归下载工具。

wget 是非交互网络检索器,主要用于获取互联网内容,基本上所有 Linux 版本都带有。

另请参阅: curl     dante-server

基本用法     详细用法

wget -r ftp://192.168.1.1
			

基本语法

wget [OPTION]... [URL]...
			

注意:

长选项强制性自变量,对于短选项也是强制性的。

Startup

参数 EN 解释 中文翻译 备注
-V, --version display the version of Wget and exit 显示 wget 版本并退出
-h, --help print this help 打印帮助信息
-b, --background go to background after startup 启动后转到后台
-e, --execute=COMMAND xecute a `.wgetrc'-style command 执行 .wgetrc 风格命令

 

Logging and input file

参数 EN 解释 中文翻译 备注
-o, --output-file=FILE log messages to FILE 把消息日志到 FILE (文件)
-a, --append-output=FILE append messages to FILE 把消息追加到 FILE (文件)
-d, --debug print lots of debugging information 打印许多调试信息
-q, --quiet quiet (no output) 安静 (不输出)
-v, --verbose be verbose (this is the default) 冗余 (这是默认值)
-nv, --no-verbose turn off verboseness, without being quiet 关闭冗余,不安静
--report-speed=TYPE output bandwidth as TYPE. TYPE can be bits 按 TYPE (类型) 输出带宽, TYPE 可以是位
-i, --input-file=FILE download URLs found in local or external FILE 下载本地发现 URL 或外部 FILE (文件)
--input-metalink=FILE download files covered in local Metalink FILE 下载本地 Metalink FILE (元链接文件) 中涵盖的文件
-F, --force-html treat input file as HTML 把输入文件视为 HTML
-B, --base=URL resolves HTML input-file links (-i -F) relative to URL 相对 URL 输入文件链接 (-i -F) 求解 HTML
--config=FILE specify config file to use 指定要使用的配置文件
--no-config do not read any config file 不读取任何配置文件
--rejected-log=FILE log reasons for URL rejection to FILE 把 URL 拒绝原因记录到 FILE (文件)

-q, --quiet 类似 -o /dev/null

譬如: wget --spider -q -o /dev/null --tries=1 -T 5 www.baidu.com

Directories

参数 EN 解释 中文翻译 备注
-nd, --no-directories don't create directories 不创建目录
-x, --force-directories force creation of directories 强制创建目录
-nH, --no-host-directories don't create host directories 不创建主机目录
--protocol-directories use protocol name in directories 使用协议目录名称
-P, --directory-prefix=PREFIX save files to PREFIX/... 保存文件到 PREFIX/...
--cut-dirs=NUMBER ignore NUMBER remote directory components 忽略 NUMBER 远程目录分量

HSTS options

参数 EN 解释 中文翻译 备注
--no-hsts disable HSTS 禁用 HSTS
--hsts-file path of HSTS database (will override default) HSTS 数据库路径 (将覆写默认)

FTP options

参数 EN 解释 中文翻译 备注
--ftp-user=USER set ftp user to USER 把 FTP 用户设为 USER
--ftp-password=PASS set ftp password to PASS 把 FTP 密码设为 PASS
--no-remove-listing don't remove `.listing' files 不移除 .listing 文件
--no-glob turn off FTP file name globbing 关闭 FTP 通配文件名
--no-passive-ftp disable the "passive" transfer mode 禁用 "被动" 传输模式
--preserve-permissions preserve remote file permissions 保留远程文件访问权限
--retr-symlinks when recursing, get linked-to files (not dir) 当递归时,获取链接-到文件 (而不是目录)

Download

参数 EN 解释 中文翻译 备注
-t, --tries=NUMBER set number of retries to NUMBER (0 unlimits) 把重试次数设为 NUMBER (0 不受限制)
--retry-connrefused retry even if connection is refused 仍重试,即使连接被拒
--retry-on-http-error=ERRORS comma-separated list of HTTP errors to retry 以逗号分隔 HTTP 错误列表,以便重试
-O, --output-document=FILE write documents to FILE 把文档写入 FILE (文件)
-nc, --no-clobber skip downloads that would download to existing files (overwriting them) 跳过下载,下载到现有文件 (覆写它们)
--no-netrc don't try to obtain credentials from .netrc 不要尝试从 .netrc 获取证书
-c, --continue resume getting a partially-downloaded file 继续获取已下载文件-部分
--start-pos=OFFSET start downloading from zero-based position OFFSET 从基于零的 OFFSET (偏移) 位置开始下载
--progress=TYPE select progress gauge type 选择进度计量类型
--show-progress display the progress bar in any verbosity mode 以任何详细模式显示进度条
-N, --timestamping don't re-retrieve files unless newer than local 不要重检索文件,除非比本地更新
--no-if-modified-since don't use conditional if-modified-since get requests in timestamping mode 在时间戳模式下,不要使用条件 if-modified-since 获取请求
--no-use-server-timestamps don't set the local file's timestamp by the one on the server 不通过某一服务器,设置本地文件时间戳
-S, --server-response print server response 打印服务器响应
--spider don't download anything 不下载任何东西
-T, --timeout=SECONDS set all timeout values to SECONDS 把所有超时值设为 SECONDS (秒)
--dns-timeout=SECS set the DNS lookup timeout to SECS 把 DNS 查找超时设为 SECS
--connect-timeout=SECS set the connect timeout to SECS 把连接超时设为 SECS
--read-timeout=SECS set the read timeout to SECS 把读取超时设为 SECS
-w, --wait=SECONDS wait SECONDS between retrievals 检索间等待 SECONDS (秒)
--waitretry=SECONDS wait 1..SECONDS between retries of a retrieval 检索重试间等待 1..SECONDS (秒)
--random-wait wait from 0.5*WAIT...1.5*WAIT secs between retrievals 检索间等待 0.5*WAIT...1.5*WAIT 秒
--no-proxy explicitly turn off proxy 明确关闭代理
-Q, --quota=NUMBER set retrieval quota to NUMBER 把检索配额设为 NUMBER
--bind-address=ADDRESS bind to ADDRESS (hostname or IP) on local host 绑定到本地主机 ADDRESS 地址 (主机名或 IP)
--limit-rate=RATE limit download rate to RATE 把下载速率限制到 RATE
--no-dns-cache disable caching DNS lookups 禁用缓存 DNS 查找
--restrict-file-names=OS restrict chars in file names to ones OS allows 限制文件名字符到某一允许 OS
--ignore-case ignore case when matching files/directories 当匹配 "文件/目录" 时,忽略大小写
-4, --inet4-only connect only to IPv4 addresses 只连接到 IPv4 地址
-6, --inet6-only connect only to IPv6 addresses 只连接到 IPv6 地址
--prefer-family=FAMILY connect first to addresses of specified family, one of IPv6, IPv4, or none 首先连接到指定系列地址,IPv6、IPv4 或 None 之一
--user=USER set both ftp and http user to USER 把 FTP 和 HTTP 两者用户设为 USER
--password=PASS set both ftp and http password to PASS 把 FTP 和 HTTP 两者密码设为 PASS
--ask-password prompt for passwords 提示密码
--use-askpass=COMMAND

specify credential handler for requesting username and password.

If no COMMAND is specified the WGET_ASKPASS or the SSH_ASKPASS environment variable is used.

指定用于请求用户名和密码的证书处理程序。

若没有指定 COMMAND,则使用 WGET_ASKPASS 或 SSH_ASKPASS 环境变量

--no-iri turn off IRI support 关闭 IRI 支持
--local-encoding=ENC use ENC as the local encoding for IRIs 把 ENC 用作本地 IRI 编码
--remote-encoding=ENC use ENC as the default remote encoding 把 ENC 用作默认远程编码
--unlink remove file before clobber 在乱码前移除文件
--keep-badhash keep files with checksum mismatch (append .badhash) 保持校验和不匹配的文件 (追加 .badhash)
--metalink-index=NUMBER Metalink application/metalink4+xml metaurl ordinal NUMBER Metalink application/metalink4+xml metaurl 序号 NUMBER
--metalink-over-http use Metalink metadata from HTTP response headers 使用来自 HTTP 响应头的 Metalink 元数据
--preferred-location preferred location for Metalink resources 首选 Metalink 资源位置

--spider 用于模拟网络蜘蛛行为访问网站, 但不下载任务内容。

譬如: wget --spider -T 5 -q -t 2 www.baidu.com

HTTP options

参数 EN 解释 中文翻译 备注
--http-user=USER set http user to USER 把 HTTP 用户设为 USER
--http-password=PASS set http password to PASS 把 HTTP 密码设为 PASS
--no-cache disallow server-cached data 禁止服务器-缓存数据
--default-page=NAME Change the default page name (normally this is `index.html') 更改默认页面名称 (通常是 'index.html')
-E, --adjust-extension save HTML/CSS documents with proper extensions 以适当扩展名保存 HTML/CSS 文档
--ignore-length ignore `Content-Length' header field 忽略头部 Content-Length 字段
--header=STRING insert STRING among the headers 在头部插入字符串
--compression=TYPE choose compression, one of auto, gzip and none 选择自动、gzip 和 none 压缩方式之一
--max-redirect maximum redirections allowed per page 允许每页最大重定向
--proxy-user=USER set USER as proxy username 把 USER 设为代理用户名
--proxy-password=PASS set PASS as proxy password 把 PASS 设为代理密码
--referer=URL include `Referer: URL' header in HTTP request 在 HTTP 请求中包括 Referer: URL 头
--save-headers save the HTTP headers to file 把 HTTP 头保存到文件
-U, --user-agent=AGENT identify as AGENT instead of Wget/VERSION 标识成 AGENT,而非 Wget/VERSION
--no-http-keep-alive disable HTTP keep-alive (persistent connections) 禁用 HTTP 保持活动 (持久连接)
--no-cookies don't use cookies 不使用 cookies
--load-cookies=FILE load cookies from FILE before session 会话前从 FILE (文件) 加载 cookies
--save-cookies=FILE save cookies to FILE after session 会话后把 cookies 保存到 FILE (文件)
--keep-session-cookies load and save session (non-permanent) cookies 加载和保存会话 (非永久) cookies
--post-data=STRING use the POST method; send STRING as the data 使用 POST 方法;把 STRING (字符串) 发送成数据
--post-file=FILE use the POST method; send contents of FILE 使用 POST 方法;发送 FILE (文件) 内容
--method=HTTPMethod use method "HTTPMethod" in the request 在请求中使用 HTTPMethod 方法
--body-data=STRING Send STRING as data. --method MUST be set 把 STRING (字符串) 发送成数据。必须设置 --method (方法)
--body-file=FILE Send contents of FILE. --method MUST be set. 发送 FILE (文件) 内容。必须设置 --method (方法)
--content-disposition honor the Content-Disposition header when choosing local file names (EXPERIMENTAL) 兑现 Content-Disposition (内容-处置) 头,当选取本地(实验)文件名时
--content-on-error output the received content on server errors 输出接收内容,当服务器出错时
--auth-no-challenge send Basic HTTP authentication information without first waiting for the server's challenge 发送基本 HTTP 验证信息,不用先等待服务器挑战

HTTPS (SSL/TLS) options

参数 EN 解释 中文翻译 备注
--secure-protocol=PR choose secure protocol, one of auto, SSLv2, SSLv3, TLSv1, TLSv1_1, TLSv1_2 and PFS 选择自动、SSLv2、SSLv3、TLSv1、TLSv1_1, TLSv1_2 及 PFS 安全协议之一
--https-only only follow secure HTTPS links 只跟随安全 HTTPS 链接
--no-check-certificate don't validate the server's certificate 不验证服务器证书
--certificate=FILE client certificate file 客户端证书文件
certificate-type=TYPE client certificate type, PEM or DER 客户端证书类型:PEM 或 DER
--private-key=FILE private key file 私钥文件
--private-key-type=TYPE private key type, PEM or DER 私钥类型:PEM 或 DER
--ca-certificate=FILE file with the bundle of CAs 带 CA 捆绑的文件
--ca-directory=DIR directory where hash list of CAs is stored CA 哈希表存储目录
--crl-file=FILE file with bundle of CRLs 带 CRL 捆绑的文件
--pinnedpubkey=FILE/HASHES

Public key (PEM/DER) file,

or any number of base64 encoded sha256 hashes preceded by 'sha256//' and separated by ';',

to verify peer against

公钥 (PEM/DER) 文件或任意数量 base64 编码的 sha256 散列,

前面加上 sha256// 并用 ;分隔,

以成对验证

--random-file=FILE file with random data for seeding the SSL PRNG 播种 SSL PRNG 随机数据文件
--ciphers=STR

Set the priority string (GnuTLS) or cipher list string (OpenSSL) directly.

Use with care. This option overrides --secure-protocol.

The format and syntax of this string depend on the specific SSL/TLS engine.

直接设置优先级字符串 (GnuTLS) 或暗号列表字符串 (OpenSSL)。

小心使用。此选项会覆盖 --secure-protocol。

此字符串的格式和语法,取决于具体 SSL/TLS 引擎。

FTPS options

参数 EN 解释 中文翻译 备注
--ftps-implicit use implicit FTPS (default port is 990) 使用隐式FTPS (默认端口是 990)
--ftps-resume-ssl resume the SSL/TLS session started in the control connection when opening a data connection 打开数据连接时,恢复控制连接启动中的 SSL/TLS 会话
--ftps-clear-data-connection cipher the control channel only; all the data will be in plaintext 只加密控制通道;所有数据将是明文
--ftps-fallback-to-ftp fall back to FTP if FTPS is not supported in the target server 如目标服务器不支持 FTPS,则回退到 FTP

 

WARC options

参数 EN 解释 中文翻译 备注
--warc-file=FILENAME save request/response data to a .warc.gz file 把 "请求/响应" 数据保存到 .warc.gz 文件
--warc-header=STRING insert STRING into the warcinfo record 把 STRING (字符串) 插入 warcinfo 记录
--warc-max-size=NUMBER set maximum size of WARC files to NUMBER 把 WARC 文件最大尺寸设为 NUMBER
--warc-cdx write CDX index files 写入 CDX 索引文件
--warc-dedup=FILENAME do not store records listed in this CDX file 不存储在此 CDX 文件中列明的记录
--no-warc-compression do not compress WARC files with GZIP 不采用 GZIP 压缩 WARC 文件
--no-warc-digests do not calculate SHA1 digests 不计算 SHA1 摘要
--no-warc-keep-log do not store the log file in a WARC record 不存储 WARC 记录日志文件
--warc-tempdir=DIRECTORY location for temporary files created by the WARC writer 由 WARC 写入器创建的临时文件位置

Recursive download

参数 EN 解释 中文翻译 备注
-r, --recursive specify recursive download 指定递归下载
-l, --level=NUMBER maximum recursion depth (int or 0 for infinite) 最大递归深度 (整数或 0 无穷大)
--delete_after delete files locally after downloading them 下载后删除本地文件
-k, --convert-links make links in downloaded HTML or CSS point to local files 使下载 HTML 或 CSS 链接指向本地文件
--convert-file-only convert the file part of the URLs only (usually known as the basename) 仅转换 URL 文件部分 (通常称为基本名称)
--backups=N before writing file X, rotate up to N backup files 在写入文件 X 之前,旋至 N 备份文件
-K, --backup-converted before converting file X, back up as X.orig 在转换文件 X 之前,将其备份成 X.orig
-m, --mirror shortcut for -N -r -l inf --no-remove-listing -N -r -l inf --no-remove-listing 的快捷方式
-p, --page-requisites get all images, etc. needed to display HTML page 获取所有图像等,需要显示 HTML 页面
--strict-comments turn on strict (SGML) handling of HTML comments 打开严格 (SGML) HTML 注释处理

Recursive accept/reject

参数 EN 解释 中文翻译 备注
-A, --accept=LIST comma-separated list of accepted extensions 可接受扩展名逗号-分隔列表
-R, --reject=LIST comma-separated list of rejected extensions 拒绝扩展名逗号-分隔列表
--accept-regex=REGEX regex matching accepted URLs 匹配可接受 URL 的正则表达式
--reject-regex=REGEX regex matching rejected URLs 匹配拒绝 URL 的正则表达式
--regex-type=TYPE regex type (posix) 正则表达式类型 (POSIX 可移植 Unix 操作系统)
-D, --domains=LIST comma-separated list of accepted domains 可接受域逗号-分隔列表
--exclude-domains=LIST comma-separated list of rejected domains 拒绝域逗号-分隔列表
--follow-ftp follow FTP links from HTML documents 跟随来自 HTML 文档的 FTP 链接
--follow-tags=LIST comma-separated list of followed HTML tags 跟随 HTML 标签的逗号-分隔列表
--ignore-tags=LIST cmma-separated list of ignored HTML tags 忽略 HTML 标签的逗号-分隔列表
-H, --span-hosts go to foreign hosts when recursive 当递归时,转到外来主机
-L, --relative follow relative links only 只跟随相对链接
-I, --include-directories=LIST list of allowed directories 允许目录列表
--trust-server-names use the name specified by the redirection URL's last component 使用由重定向 URL 最后分量,指定的名称
-X, --exclude-directories=LIST list of excluded directories 排除目录列表
-np, --no-parent don't ascend to the parent directory 不上升到父级目录

基本用法

功能 命令 文字解释 示例 示例解释
获取 wget Archive-Link 获取 Archive-Link 存档 wget https://www.sqlite.org/2020/sqlite-doc-3310100.zip 下载 sqlite-doc-3310100.zip 到当前目录
帮助 wget -h 展示帮助信息
wget --help
版本 wget -V 展示版本信息
wget --version

 

版权声明: 本文为独家原创稿件,版权归 乐数软件 ,未经许可不得转载。