Linux command
wget 命令
网络
需要网络或远程资源。
常用示例
Download a file
wget [https://example.com/file]
Download with custom output name
wget -O [filename] [url]
Download to specific directory
wget -P [directory] [url]
Continue a partial download
wget -c [url]
Download in background
wget -b [url]
Download recursively
wget -r [url]
Download with authentication
wget --user=[username] --password=[password] [url]
Limit download speed
wget --limit-rate=[200k] [url]
Download from a list of URLs
wget -i [urls.txt]
说明
wget is a non-interactive network downloader supporting HTTP, HTTPS, and FTP. It can download files, follow links, and mirror entire websites while handling interruptions and retrying failed transfers. For simple downloads, wget automatically names the output file from the URL. Use -O to specify a different name or -O - to output to stdout. Recursive downloading with -r follows links and downloads connected pages. Combine with -l to limit depth, -k to convert links for offline browsing, and -p to get page resources. Wget handles redirects, cookies, and authentication automatically. It's scriptable and works well for automated downloads and cron jobs.
参数
- -O _file_
- Write to specified file
- -P _prefix_
- Save to specified directory
- -c, --continue
- Resume partial download
- -b, --background
- Go to background after starting
- -q, --quiet
- Quiet mode (no output)
- -r, --recursive
- Recursive download
- -l _depth_, --level=_depth_
- Maximum recursion depth (0 = infinite)
- -k, --convert-links
- Convert links for local viewing
- -p, --page-requisites
- Download all page requirements (images, CSS, etc.)
- -m, --mirror
- Mirror mode (-r -N -l inf --no-remove-listing)
- -i _file_, --input-file=_file_
- Read URLs from file
- --limit-rate=_rate_
- Limit download speed
- --user=_user_, --password=_pass_
- HTTP/FTP authentication
- -U _agent_, --user-agent=_agent_
- Set User-Agent header
- --no-check-certificate
- Don't validate SSL certificates
- --header=_string_
- Send additional HTTP header
FAQ
What is the wget command used for?
wget is a non-interactive network downloader supporting HTTP, HTTPS, and FTP. It can download files, follow links, and mirror entire websites while handling interruptions and retrying failed transfers. For simple downloads, wget automatically names the output file from the URL. Use -O to specify a different name or -O - to output to stdout. Recursive downloading with -r follows links and downloads connected pages. Combine with -l to limit depth, -k to convert links for offline browsing, and -p to get page resources. Wget handles redirects, cookies, and authentication automatically. It's scriptable and works well for automated downloads and cron jobs.
How do I run a basic wget example?
Run `wget [https://example.com/file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -O _file_ do in wget?
Write to specified file