承接參數大全,本文精選 11 個高頻實戰場景,提供可直接複製執行的指令範例,涵蓋單檔、目錄、整站鏡像、批次清單、代理、限速、離線瀏覽等需求。
wget https://example.com/file.zip
wget -bc https://mirror.example.com/CentOS-7-x86_64-DVD.iso
wget -p -k https://example.com/page.html
wget -c -r -np -k -L -p https://example.com/pub/path/
wget -np -nH -r --span-hosts -D example.com,cdn.example.com https://example.com/pub/path/
wget -m -l4 -t0 https://www.example.edu.cn
# -m = -r -l inf -N --no-remove-listing
# -l4 限制深度 4 層
# -t0 無限重試
wget -r -L -R gif,jpg,png https://www.example.edu.cn/doc/
wget -r -k -p -np -E -I blog,wiki https://www.example.edu.cn
wget -r -nH -nd https://mirror.example.com/redhat/9/i386/updates/RPMS/
wget -i download.txt -o download.log
# 環境變數法
export http_proxy=https://proxy:3128
export https_proxy=https://proxy:3128
wget -i download.txt -o download.log
# 參數法
wget --proxy-user=u --proxy-password=p -i download.txt -o download.log
wget -t 0 -w 31 -c https://example.com/large.avi -o down.log &
# 或從檔案讀取列表,指定 FTP 基底路徑
wget -t 0 -w 31 -c -B ftp://example.com/linuxsoft -i filelist.txt -o down.log &
| 參數 | 含義 |
|---|---|
| -c | 續傳 |
| -r | 遞迴 |
| -np | 不上溯父目錄 |
| -k | 轉相對連結 |
| -L | 不跟隨外部主機 |
| -p | 下載頁面資源 |
| -A/-R | 接受/拒絕副檔名 |
| -I/-X | 接受/拒絕目錄 |
| -E | HTML 強制 .html 副檔名 |
| -nH | 不建立主機名目錄 |
| -nd | 不建立任何目錄 (扁平化) |
| --cut-dirs=N | 忽略前 N 層遠端目錄 |
| -H | 允許跨主機 |
| -D | 限制域名 (配合 -H) |