wget Download the ultimate usage and 15 detailed examples

Source: Internet
Author: User

Wget is a very useful Internet download tool, he has a lot of features are not comparable to other tools, and he is a lightweight configurable download tool.

This article combines examples to introduce a variety of download methods and uses for Windows wget.

1. Download individual files with wget

The download will show:

~ File size, connection status, connection address, and file size

~ Saved Name

~ Download progress bar

~ Download speed, time, and how much has not been downloaded

For example, when I download EditPlus, I enter

wget http://software-files-a.cnet.com/s/software/12/32/81/47/
epp331.exe?token=1329413178_4553efa847829f3ecef10c1bc256fcc0&lop=link&ptype=3001
&ontid=2352&siteid=4&edid=3&spi=537d5d5485f688682d82c481c4fb15a1&pid=12328147&ps
Id=10018241&&filename=epp331.exe

The following will be displayed when downloading


wget http://software-files-a.cnet.com/s/software/12/32/81/47/
Epp331.exe?token=1329413178_ 4553efa847829f3ecef10c1bc256fcc0&lop=link&ptype=3001
&ontid=2352&siteId=4&edId=3& Spi=537d5d5485f688682d82c481c4fb15a1&pid=12328147&ps
Id=10018241&&filename=epp331.exe
-- 2012-02-16 15:28:50--  HTTP://SOFTWARE-FILES-A.CNET.COM/S/SOFTWARE/12/32/81/47
/epp331.exe?token= 1329413178_4553EFA847829F3ECEF10C1BC256FCC0
Resolving software-files-a.cnet.com ... 204.2.171.33, 204.2.171.35
Connecting to software-files-a.cnet.com|204.2.171.33|:80 ... connected.
HTTP request sent, awaiting response ... $ OK
length:1766464 (1.7M) [Application/octet-stream]
Saving to: '

18% [======>] 335,238 20.5k/s ETA 64s


2, with Wget-o download can specify a different name for the downloaded file

By default, Wget uses all the characters that follow the last slash to name the downloaded file, as shown in the previous example, where the file is saved as

Saving to: '[email protected]=1329413178_4553efa847829f3ecef10c1bc256fcc0 '

This is not what we want, we can use the-o option to change the save file to Editplus.exe


Wget-o Editplus.exe http://software-files-a.cnet.com/s/software/12/32/81/47/
epp331.exe?token=1329413178_4553efa847829f3ecef10c1bc256fcc0&lop=link&ptype=3001
&ontid=2352&siteid=4&edid=3&spi=537d5d5485f688682d82c481c4fb15a1&pid=12328147&ps
Id=10018241&&filename=epp331.exe

3, using wget--limit-rate to specify the speed of the download

As the following example limits the speed to 300k

wget--limit-rate=300k Http://downloads.sourceforge.net/project/boost/boost-doc
s/1.47.0/boost_1_47_pdf.zip?r=http%3a%2f%2fsourceforge.net%2fprojects%2fboost%2f
&ts=1329379231&use_mirror=nchc

4, continue to download with Wget-c

When you download a large file and suddenly break down then this option comes in handy.

Wget-c Http://downloads.sourceforge.net/project/boost/boost-doc
s/1.47.0/boost_1_47_pdf.zip?r=http%3a%2f%2fsourceforge.net%2fprojects%2fboost%2f
&ts=1329379231&use_mirror=nchc

5, background download with Wget-b

When downloaded with this option, only the download is initialized and no related information is displayed


Wget-b http://downloads.sourceforge.net/project/boost/boost-
Docs/1.47.0/boost_1_47_pdf.zip?r=http%3a%2f%2fsourceforge.net%2fprojects%2fboost
%2f&ts=1329379231&use_mirror=nchc
Continuing in background, PID 6132.
Output'll is written to ' Wget-log '.

After the download will be in the wget directory production of Wget-log files, open with Notepad to see the contents of the content as shown below


--2012-02-16 16:12:55--  http://downloads.sourceforge.net/project/boost/boost-docs/1.47.0/boost_1_47 _PDF.ZIP?R=HTTP%3A%2F%2FSOURCEFORGE.NET%2FPROJECTS%2FBOOST%2F
Resolving downloads.sourceforge.net ... 216.34.181.59
Connecting to downloads.sourceforge.net|216.34.181.59|:80 ... connected.
HTTP request sent, awaiting response ... 302 Found
Location:http://nchc.dl.sourceforge.net/project/boost/boost-docs/1.47.0/boost_1_47_pdf.zip [ Following]
--2012-02-16 16:12:56--  http://nchc.dl.sourceforge.net/project/boost/boost-docs/1.47.0/boost _1_47_pdf.zip
Resolving nchc.dl.sourceforge.net ... 211.79.60.17
Connecting to nchc.dl.sourceforge.net|211.79.60.17|:80 ... connected.
HTTP request sent, awaiting response ... $ OK
length:31421410 (30M) [Application/zip]
Saving to: ' BOOST_1_47_PDF.ZIP.4 '

0K ..... ..... ..... ..... ..... ..... ..... ....... ............ 0% 19.7K 25m51s
50K ..... ..... ..... ..... ..... ..... ..... ....... ............ 0% 29.1K 21m40s
100K ..... ..... ..... ..... ..... ..... ..... ....... ............ 0% 20.8K 22m35s
150K ..... ..... ..... ..... ..... ..... ..... ....... ............ 0% 19.5K 23m26s
200K ..... ..... ..... ..... ..... ..... ..... ....... ............ 0% 18.4K 24m13s
250K ..... ..... ..... ..... ..... ..... ..... ....... ............ 0% 20.8K 24m13s
300K ..... ..... ..... ..... ..... ..... ..... ....... ............ 1% 18.2K 24m41s
350K ..... ..... ..... ..... ..... ..... ..... ....... ............ 1% 23.5K 24m16s


6. Test the address you want to download with wget--spider

wget--spider Download-url

If the given URL is correct, it will be displayed


Resolving downloads.sourceforge.net ... 216.34.181.59
Connecting to downloads.sourceforge.net|216.34.181.59|:80 ... Connected.
HTTP request sent, awaiting response ... 302 Found
Location:http://ncu.dl.sourceforge.net/project/boost/boost-docs/1.47.0/boost_1_
47_pdf.zip [following]
Spider mode enabled. Check if remote file exists.
--2012-02-16 16:21:08--http://ncu.dl.sourceforge.net/project/boost/boost-docs/
1.47.0/boost_1_47_pdf.zip
Resolving ncu.dl.sourceforge.net ... 140.115.17.45
Connecting to ncu.dl.sourceforge.net|140.115.17.45|:80 ... Connected.
HTTP request sent, awaiting response ... OK
length:31421410 (30M) [Application/zip]
Remote file exists.

otherwise displayed


Spider mode enabled. Check if remote file exists.
--2012-02-16 16:23:06--http://downloads.sourceforge.net/project/boost/boost-do
Cs/1.47.0/boost_1_47_pdf222.zip?r=http%3a%2f%2fsourceforge.net%2fprojects%2fboos
t%2f
Resolving downloads.sourceforge.net ... 216.34.181.59
Connecting to downloads.sourceforge.net|216.34.181.59|:80 ... Connected.
HTTP request sent, awaiting response ... 404 Not Found
Remote file does not exist--broken link!!!

7, increase the number of re-connect with wget-tries

In the case of network problems the second option is especially useful, by default wget will be re-connected 20 times to successfully complete the download, we can increase him as we expect the number of times

wget--tries=100 Download-url


8. Download multiple files/urls with Wget-i

Start by saving all the files or URLs you want to download into a notepad, such as Aa.txt, with the following content

URL1
URL2
URL3
URL4

Next, enter the following code to bulk download

Wget-i Aa.txt

9, download a complete website with Wget-mirror

The following implementation is you want to complete download a website for local browsing

wget--mirror-p--convert-links-p Local-dir website-url

--mirror: Turn on mirroring option

-P: Download all files necessary to display a given URL

--convert-links: After downloading, the conversion link is used for local display

-P Local_dir: Save all Files or directories to the specified directory

10, save output to log file instead of standard output with Wget-o

Use the following code when you want to save the information to a file instead of displaying it in the terminal.

Wget-o Download.log Download-url

11. Terminate the download with Wget-q when the specified size is exceeded

When the file has been downloaded 10M, at this point you want to stop the download can use the following command line

Wget-q10m-i File-which-has-urls

Note: This option is only useful when downloading multiple files, which is useless when you download a file.

12. Download files of specific file types with Wget-r-a

You can download the file in this way:

~ Download all pictures from a website
~ Download all videos from one website

~ Download all PDF files from one website

Wget-r-a.pdf http://url-to-webpage-with-pdfs/

13, specify not to download a certain type of file with wget--reject

You find a website useful, but you do not want to download the above image, because it is too much traffic, at this time you can use the following command.

wget--reject=gif website-to-be-downloaded


14, using wget to achieve FTP download

For anonymous FTP download

wget Ftp-url

FTP download with user name and password

wget--ftp-user=username--ftp-password=password Download-url

15, wget download Some resources must use the option--no-check-certificate, otherwise will prompt no authentication does not allow the download

wget--no-check-certificate URL

wget Download the ultimate usage and 15 detailed examples

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.