Note: options ARE case sensitive.
1. Download a single file with wget using no options.
wget http://ftp.gnu.org/gnu/wget/wget-latest.tar.gzWhile downloading, wget will display a progress bar with the following information:
- % of download completion
- Download progress in bytes
- Current download speed
- Estimated time remaining
Completed download
2. Download a file saving with a different name using wget -O
wget http://www.vim.org/scripts/download_script.php?src_id=7701Even though the downloaded file is in zip format, it will be saved with the name download_script.php?src_id=7701 without the -O switch.
To modify this behavior specify the output file name using the -O option.
wget -O taglist.zip http://www.vim.org/scripts/download_script.php?src_id=77013. Specify download speed / download rate Using wget –limit-rate
While executing the wget, by default it will try to use all possible bandwidth. You can limit the download speed using the –limit-rate switch.
wget --limit-rate=200k http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz4. Restart a download which stopped in the middle using wget -c.
wget -c http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz5. Download in the background with wget -b
wget -b http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz
The download will begin and give back the shell prompt to you. You can always check the status of the download using tail -f (Linux only) .
tail -f wget-log6. Mask user agent and display wget like browser using wget –user-agent
Some websites can disallow you to download its page by identifying that the user agent is not a browser. So you can mask the user agent by using –user-agent options and show wget like a browser.
wget --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3" http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz7. Test URL using wget –spider. This will test that the file exists, but not perform the download.
wget --spider http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz
8. Increase total number of retry attempts using wget –tries.
wget --tries=75 http://ftp.gnu.org/gnu/wget/wget-latest.tar.gz9. Download multiple files / URLs using wget -i
First, store all the download files or URLs in a text file:
URL1
URL2
URL3
URL4
Next, give the download-file-list.txt as argument to wget using -i option.
wget -i download-file-list.txt10. Download a full website using wget –mirror
wget --mirror -p --convert-links -P ./LOCAL-DIR WEBSITE-URL
- –mirror: enable mirroring
- -p: download all files that are necessary to properly display a given HTML page
- –convert-link: after the download, convert the links in document for local viewing
- -P ./LOCAL-DIR: save all the files and directories to the specified directory
wget --reject=gif WEBSITE-TO-BE-DOWNLOADED12. Log messages to a log file instead of stderr using wget -o. To redirect output to a log file instead of the terminal.
wget -o download.log DOWNLOAD-URL13. Quit downloading when certain size is exceeded using wget -Q.
wget -Q5m -i FILE-WHICH-HAS-URLS14. Download only certain file types using wget -r -A
You can use this for the following situations
- Download all images from a website
- Download all videos from a website
- Download all PDF files from a website
wget -r -A.pdf http://url-to-webpage-with-pdfs/15. You can use wget to perform FTP downloads.
wget ftp-urlFTP download using wget with username and password authentication.
wget --ftp-user=USERNAME --ftp-password=PASSWORD DOWNLOAD-URLNote: username and password can be used for HTTP and HTTPS downloads as well using --http-user=USER, --http-password=PASS respectively.
More
You guys rock!
ReplyDeletecan wget be used for a local file, that is, a file already on my computer. if not, what should be used?
ReplyDelete