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 風格命令 |
| 參數 | 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 |
| 參數 | 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 |
版權聲明: 本文為獨傢原創稿件,版權歸 樂數軟件 ,未經許可不得轉載。