คู่มือครบครันสำหรับ wget - Command Line Downloader ที่ทรงพลัง รองรับ Resume, Recursive, Mirror, Authentication, Bandwidth Control
ติดตั้ง wget
# Ubuntu/Debian
sudo apt install wget
# CentOS/RHEL/Fedora
sudo dnf install wget
# macOS
brew install wget
# Windows: Chocolatey/Scoop หรือ Binary จาก GNUWin32
คำสั่งพื้นฐาน
# ดาวน์โหลดไฟล์เดี่ยว
wget https://example.com/file.zip
# ระบุชื่อไฟล์เอาต์พุต
wget -O myfile.zip https://example.com/file.zip
# ดาวน์โหลดหลายไฟล์
wget -i urls.txt # urls.txt มี URL ทีละบรรทัด
Resume Download (ต่อจากที่หยุด)
wget -c https://example.com/large-file.iso
# -c = continue (Resume)
Bandwidth Control
# จำกัดความเร็ว 1MB/s
wget --limit-rate=1m https://example.com/file.zip
# จำกัด 500KB/s
wget --limit-rate=500k https://example.com/file.zip
Recursive Download (Mirror Website)
# ดาวน์โหลดเว็บไซต์ (Depth 1)
wget -r -l 1 https://example.com/
# Mirror ทั้งไซต์ (สำหรับ Backup)
wget --mirror -p --convert-links -P ./backup https://example.com/
# เฉพาะไฟล์ .jpg
wget -r -l 1 -A.jpg https://example.com/
# ไม่ขึ้นไป Parent Directory
wget -r --no-parent https://example.com/dir/
Authentication
# Basic Auth
wget --user=username --password=pass https://example.com/protected/file
# หรือใน URL
wget https://user:pass@example.com/file
# Cookie (สำหรับ Site ต้อง Login)
wget --load-cookies cookies.txt https://example.com/
ตัวเลือกสำคัญอื่นๆ
| Option | คำอธิบาย |
|---|---|
-q | Quiet (ไม่แสดง Progress) |
-nv | Non-verbose (แสดงแค่ Error) |
-v | Verbose (Debug) |
--timeout=30 | Timeout วินาที |
--tries=3 | Retry ครั้ง |
--wait=1 | Wait ระหว่าง Request (Polite) |
--random-wait | Wait Random 0.5-1.5x |
--user-agent="..." | Custom User Agent |
--no-check-certificate | Skip SSL Verify (ไม่แนะนำ) |