wget Download Tool

Source: Internet
Author: User
Tags file url ftp site mirror website

Transferred from: http://www.jb51.net/LINUXjishu/86326.html

1. Use wget to download individual files

1 e.g. 2 3 wget http://45#下载文件, and saved in the current directory under 6 #下载过程显示进度条, Current download speed, remaining download time, etc.

2. Download with Wget-o and save it with a different file name

1 e.g.2 3wget http://www.centos.bz/download?id=10804 5#默认保存在当前目录下的文件名为路径中最后一个 "/"after the string name;6#对于动态链接 (above), the saved file is named "download?id= the", the file name is not legal. 7 8#解决办法:9#通过-o option to specify a file name. Ten  One e.g. A  -Wget-o Wordpress.zip http://www.centos.bz/download.php?id=1080

3, use wget–limit-rate speed limit download

-limit-rate: Speed limit download E.g.wget–limit-rate=300k http://# Default for all possible broadband downloads # speed limit download, You can create conditions for other downloads

4. Use wget-c breakpoint to continue transmission

1 -C: Breakpoint continuation 2e.g.34 wget-c http://5 6 # Unexpected interrupt, can be re-downloaded

5, use wget-b background download

1 -b: Background download 2  3e.g.  4  5 wget-b http://  6 inch 1840  7 Output would be written to ' wget-   8  9# View Download Progress 10   One

6. Disguise Agent name Download

1 –user-agent23e.g.45 wget–user-agent= "mozilla/ 5.0 6.1; En-US) applewebkit/534.16 (khtml, like Gecko) chrome/10.0. 648.204 safari/534.16″

7. Use wget–spider test Download link

1 –spider 2 3  45# for 678

If the download link is correct, it will show
Wget–spider URL
Spider mode enabled. Check if remote file exists.
HTTP request sent, awaiting response ... OK
length:unspecified [text/html]
Remote file exists and could contain further links,
But recursion is disabled-not retrieving.

Given the wrong link, the following error will be displayed
Wget–spider URL
Spider mode enabled. Check if remote file exists.
HTTP request sent, awaiting response ... 404 Not Found
Remote file does not exist-broken link!!!
8. Use Wget–tries to increase the number of retries

1 wget–tries=

9. Download multiple Files using Wget-i

First, save a copy of the download link file

Cat > Filelist.txt
Url1
Url2
Url3
Url4
Then use this file and parameters-I download

Wget-i filelist.txt

10. Using Wget–mirror Mirror website
The following example is to download the entire website to local.

Wget–mirror-p–convert-links-p./local URL
–miror: Account opening image download
-P: Download all HTML pages showing normal files
–convert-links: After download, convert cost to link
-P./local: Save all files and directories to a locally specified directory

11, use wget–reject filter specified format download
You want to download a website, but you do not want to download pictures, you can use the following commands.

Wget–reject=gif URL

12. Use Wget-o to save the download information to the log file
You do not want the download information to be displayed directly in the terminal but in a log file, you can use the following command:

Wget-o Download.log URL

13, use wget-q limit the total download file size
When you want to download more than 5M files and exit the download, you can use the following command:

Wget-q5m-i filelist.txt
Note: This parameter does not work for a single file download and is only valid for recursive downloads.

14. Use Wget-r-A to download the specified format file
You can use this feature in the following situations

Download all pictures of a website
Download all videos of a website
Download all PDF files for a website
Wget-r-a.pdf URL

15, using wget FTP download
You can use wget to complete the download of the FTP link.
Using wget anonymous FTP download

wget Ftp-url

FTP download with wget user name and password authentication

Wget–ftp-user=username–ftp-password=password URL

Wget is an open source software developed under Linux, the author is Hrvoje Niksic, which was later ported to various platforms, including Windows. It has the following features and features:

(1) Support the breakpoint down-pass function; This is also the network Ant and flashget the biggest selling point of the year, now, wget can also use this feature, those networks are not too good users can rest assured;
(2) Support both FTP and HTTP download mode, although most of the software can now be downloaded using HTTP, but, in some cases, still need to use FTP mode to download software;
(3) Support proxy server; For a system with high security intensity, it is generally not to expose its own system directly to the Internet, so the support agent is the necessary function to download the software;
(4) easy to set up; maybe, accustomed to GUI user is not too accustomed to command line, but, the command line in the settings actually have more advantages, at least, the mouse can be a little bit less many times, do not worry about whether the mouse is wrong point;
(5) The procedure is small, completely free, the program is small can be considered, because the current hard disk is too big, completely free to consider, even if there are many so-called free software, but these software ads are not our favorite;

Although wget is powerful, it is relatively simple to use, and the basic syntax is: wget [parameter list] URL. Here are some examples to illustrate the use of wget.

1, download the entire HTTP or FTP site.
wget Http://place.your.url/here
This command can download the Http://place.your.url/here home page. Using-X forces a directory to be identical on the server, and if you use the-nd parameter, all content downloaded by the server is added to the local current directory.

Wget-r Http://place.your.url/here
This command will follow the recursive method of downloading all directories and files on the server, essentially downloading the entire site. This command must be used with caution, because at the time of download, all the addresses that the downloaded site points to are also downloaded, so if the site references other sites, the referenced sites will be downloaded as well! For this reason, this parameter is not commonly used. You can use the-l number parameter to specify the level of the download. For example, to download only two tiers, use-l 2.

If you want to create a mirror site, you can use the-m parameter, for example: Wget-m http://place.your.url/here
At this point wget will automatically determine the appropriate parameters to make the mirror site. At this point, wget will log on to the server, read into the robots.txt and follow the robots.txt rules.

2, the breakpoint continues to pass.
When the file is particularly large or the network is particularly slow, often a file has not been downloaded, the connection has been cut off, at this point, the need to continue to pass the breakpoint. Wget's breakpoint continuation is automatic and requires only the-c parameter, for example:
Wget-c Http://the.url.of/incomplete/file
Using a breakpoint to resume requires the server to support the continuation of the breakpoint. The-t parameter indicates the number of retries, such as the need to retry 100 times, then write-T 100, if set to-T 0, indicates an infinite retry until the connection succeeds. The-t parameter indicates a time-out wait, such as-t 120, which means that waiting for 120 seconds does not connect even if it times out.

3, Bulk download.
If you have more than one file to download, you can generate a file, write one line for each file URL, such as generate file Download.txt, and then use the command: Wget-i download.txt
This will download each URL listed in Download.txt. (If the column is a file to download the file, if the column is a site, then download the first page)

4, Selective download.
You can specify that you want wget to download only one type of file, or not to download it. For example:
Wget-m–reject=gif http://target.web.site/subdirectory
Indicates that the http://target.web.site/subdirectory is downloaded, but the GIF file is ignored. –accept=list can accept the file type, –reject=list rejects the accepted file type.

5, Password and authentication.
Wget can only handle websites that restrict access using username/password, with two parameters:
–http-user=user setting up an HTTP user
–http-passwd=pass Setting the HTTP password
For sites that require certificates for certification, you can only use other download tools, such as curl.

6, the use of Proxy server for download.
If the user's network needs to go through a proxy server, then you can let wget through the proxy server for file download. At this point, you need to create a. wgetrc file in the current user's directory. You can set up a proxy server in the file:
Http-proxy = 111.111.111.111:8080
Ftp-proxy = 111.111.111.111:8080
Represents the proxy server for HTTP and the proxy server for FTP, respectively. If the proxy server requires a password, use:
–proxy-user=user setting up a proxy user
–proxy-passwd=pass Setting the proxy password
These two parameters.
Use the parameter –proxy=on/off or close the agent.
Wget also has a lot of useful features that users need to dig into.

Appendix:

Command format:
wget [parameter list] [target software, Web page URL]

-v,–version Display the software version number and then exit;
-H,–HELP display software help information;
-e,–execute=command execute a ". Wgetrc" command

-o,–output-file=file Save the software output information to a file;
-a,–append-output=file Append the software output information to the file;
-d,–debug display output information;
-q,–quiet does not display output information;
-i,–input-file=file get the URL from the file;

-t,–tries=number Download count (0 = infinite)
-o–output-document=file download file to another file name
-nc,–no-clobber do not overwrite files that already exist
-n,–timestamping only download newer files than the local
-t,–timeout=seconds setting the time-out period
-y,–proxy=on/off Closing the agent

-nd,–no-directories do not create a directory
-x,–force-directories forcing a directory to be established

–http-user=user setting up an HTTP user
–http-passwd=pass Setting the HTTP password
–proxy-user=user setting up a proxy user
–proxy-passwd=pass Setting the proxy password

-r,–recursive Download the entire website, directory (use caution)
-l,–level=number Download Hierarchy

-a,–accept=list types of files that can be accepted
-r,–reject=list rejected file types
-d,–domains=list domain names that can be accepted
–exclude-domains=list denied domain name
-l,–relative Download Associated Links
–follow-ftp Download Only FTP links
-h,–span-hosts can download the outside host
-i,–include-directories=list Allowed Directories
Directories rejected by-x,–exclude-directories=list

The Chinese document name is encoded in the usual situation, but it is normal when –cut-dirs,
Wget-r-np-nh–cut-dirs=3 ftp://host/test/
Test. txt
Wget-r-np-nh-nd ftp://host/test/
%b4%fa%b8%d5.txt
wget "ftp://host/test/*"
%b4%fa%b8%d5.txt

Due to unknown reasons, it may be to avoid the special file name, wget will automatically take the part of the grab file name encode_string processed, so the patch will be encode_string processed into "%3a" this thing, with Decode_string restore into ":" and applies to the part of the directory and the file name, Decode_string is the wget built-in function.

Wget-t0-c-nh-x-np-b-m-p/home/sunny/nod32view/http://downloads1.kaspersky-labs.com/bases/-o wget.log

wget Download Tool

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.