wget Download the ultimate usage and 15 detailed examples

Source: Internet
Author: User

Wget is a very useful Internet download tool, he has many features that other tools can not match, and he is a lightweight configurable download tool.

This article combines examples to introduce the various downloading methods and uses of wget under Windows.

1. Download a single file with wget

The download will show:

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

~ Saved by name

~ Download progress bar

~ Download speed, time, and how many have not been downloaded

For example, when I download EditPlus, enter

D:\Hack stuff\wget>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

D:\Hack stuff\wget>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: ' Epp331.exe@token=1329413178_ 4553efa847829f3ecef10c1bc256fcc0 '

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


2, with Wget-o download can be used to download the file to specify a different name

By default, wget will name the downloaded file with all characters following the last slash, as shown in the previous example, which has the file name

Saving to: ' EPP331.EXE@TOKEN=1329413178_4553EFA847829F3ECEF10C1BC256FCC0 '

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

D:\Hack stuff\wget>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, with wget--limit-rate specify the speed of download

The following example limits the speed to 300k

D:\Hack stuff\wget>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

This option comes in handy when you're suddenly interrupted while downloading a large file.

D:\Hack stuff\wget>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

Downloading with this option will only initialize the download without displaying the relevant information

D:\Hack stuff\wget>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 would be written to ' Wget-log '.

After the download will be in the wget directory to produce wget-log files, with Notepad open to see the contents as follows

--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 is 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 show

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 wget-tries with the

In the case of network problems, the option is particularly useful, the default is wget will be repeated 20 times to successfully complete the download, we can add him to the number of times we expect

wget--tries=100 Download-url


8, download multiple files/urls with Wget-i

First Save all the files or URLs you want to download into a notepad, such as Aa.txt, which reads as follows

URL1
URL2
URL3
URL4

Next, enter the following code can be downloaded in bulk

Wget-i Aa.txt

9, download a complete site with Wget-mirror

The following implementation is you want to complete the download of a Web site for local browsing

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

--mirror: Open 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 the terminal display.

Wget-o Download.log Download-url

11, when exceeding the specified size to terminate the download with Wget-q

When the file has been downloaded 10M, you may want to stop downloading at this time using the following command line

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

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

12, download specific file types of files with Wget-r-A

You can download the file in this way:

~ Download all pictures 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/

13, specify not to download a type of document with Wget--reject

You find a site useful, but you do not want to download the above picture, because too much traffic, at this point you can use the following command.

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


14, using wget to achieve FTP download

Anonymous FTP Downloads

wget Ftp-url

FTP download with username and password

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

15, wget download the resources must use the option--no-check-certificate, otherwise will be prompted no certification does not allow download

wget--no-check-certificate URL


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.