Centos wget command for downloading files

Source: Internet
Author: User
Wget is the most common download command in linux. the general usage is: wget + space + url path of the file to be downloaded, for example: # wgetlinuxsense.org/xxxx/xxx.tar.gz "& gt; http://www.linuxsense.org/xxxx/xxx.tar.gzsimply says that wget is the most common download command in linux. generally, wget + space + url path of the file to be downloaded

Example: # wget linuxsense.org/xxxx/xxx.tar.gz "> http://www.linuxsense.org/xxxx/xxx.tar.gz

To put it simply, The-c parameter is also very common. it can be resumable data transfer. if it is terminated accidentally, you can continue to use the command to download it.

Example: # wget-c http://www.linuxsense.org/xxxx/xxx.tar.gz

The following describes the usage of wget in detail:

Wget is a free tool for automatically downloading files from the network. It supports HTTP, HTTPS, and FTP protocols and can use HTTP proxy.

The so-called automatic download means that wget can be executed in the background after the user exits the system. This means that you can log on to the system, start a wget download task, and exit the system. wget will be executed in the background until the task is completed, compared with most other browsers, users need to participate in downloading a large amount of data, which saves a lot of trouble.

Wget allows you to track links on the HTML page and download them to create the local version of the remote server, completely recreating the directory structure of the original site. This is often called recursive download ". During recursive download, wget complies with the Robot Exclusion standard (/robots.txt). wget can convert the link to a local file while downloading to facilitate offline browsing.

Wget is very stable. it has strong adaptability to unstable networks with narrow bandwidth. if the download fails due to network reasons, wget keeps trying until the entire file is downloaded. If the server interrupts the download process, it will be again connected to the server to continue the download from the stopped place. This is very useful for downloading large files from servers with limited connection time.

Common wget usage

Wget format

Usage: wget [OPTION]… [URL]…

* Use wget as the site image:

Wget-r-p-np-k http://dsec.pku.edu.cn /~ Usr_name/

# Or

Wget-m http://www.tldp.org/LDP/abs/html/

* Download a part of the downloaded files from an unstable network and during free time

Wget-t 0-w 31-c http://dsec.pku.edu.cn/BBC.avi-o down. log &

# Or read the list of files to be downloaded from filelist

Wget-t 0-w 31-c-B ftp://dsec.pku.edu.cn/linuxsoft-I filelist.txt-o down. log &

The above code can also be used for downloading when the network is relatively idle. My usage is: in mozillawill not easily download the urlchain to the memory, then paste it to the filelist.txt file, and execute the second code above before going out of the system at night.

* Download via proxy

Wget-Y on-p-k https://sourceforge.net/projects/wvware/

The proxy can be set in the environment variable or wgetrc file.

# Set proxy in environment variables

Export PROXY = http: // 211.90.168.94: 8080/

# In ~ /. Set proxy in wgetrc

Http_proxy = http://proxy.yoyodyne.com: 18023/

Ftp_proxy = http://proxy.yoyodyne.com: 18023/

Wget option Category List

* Start

-V ,? The version displays the wget version and then exits.

-H ,? Help print syntax help

-B ,? After the background is started, it is transferred to the background for execution.

-E ,? Execute = COMMAND: execute the COMMAND in the '. wgetrc' format. for the wgetrc format, see/etc/wgetrc or ~ /. Wgetrc

* Record and input files

-O ,? Output-file = FILE: write the record to the FILE.

-,? Append-output = FILE: append the record to the FILE.

-D ,? Debug print debugging output

-Q ,? Quiet mode (no output)

-V ,? Verbose lengthy mode (this is the default setting)

-Nv ,? Non-verbose turns off the lengthy mode, but not the quiet mode

-I ,? Input-file = download the URLs FILE that appears in the FILE.

-F ,? Force-html treats input files as HTML files

-B ,? Base = URL uses the URL as the prefix of the relative link in the file specified by the-F-I parameter

? Sslcertfile = FILE (optional) client certificate

? Sslcertkey = KEYFILE the KEYFILE of the client certificate is optional.

? Egd-file = FILE specifies the file name of the EGD socket.

 

* Download

? Bind-address = ADDRESS specifies the local address (host name or ip address, used when there are multiple local IP addresses or names)

-T ,? Tries = NUMBER sets the maximum NUMBER of attempts (0 indicates no limit ).

-O? Output-document = FILE: write the document to the FILE.

-Nc ,? No-clobber do not overwrite existing files or use. # prefix

-C ,? Continue to download files that have not been downloaded

? Progress = TYPE sets the process bar flag

-N ,? Timestamping: Do not re-download files except for non-newer than local files

-S ,? Server-response print server response

? Spider does not download anything

-T ,? Timeout = SECONDS: set the number of SECONDS for response timeout

-W ,? Wait = SECONDS interval between two attempts: SECONDS

? Waitretry = SECONDS wait 1... SECONDS

? Random-wait waits for 0 to download... 2 * WAIT seconds

-Y ,? Proxy = on/off open or close proxy

-Q ,? Quota = NUMBER sets the download capacity limit

? Limit-rate = RATE: specifies the download rate.

* Directory

-Nd? No-directories does not create a directory

-X ,? Force-directories force directory creation

-NH ,? No-host-directories does not create a host Directory

-P ,? Directory-prefix = PREFIX save the file to the directory PREFIX /...

? Cut-dirs = NUMBER ignore the remote directory at the NUMBER layer

* HTTP options

? Http-user = USER: Set the http user name to user.

? Http-passwd = PASS: Set the http password to PASS.

-C ,? Cache = on/off allows/does not allow data caching on the server (usually ).

-E ,? Html-extension saves all text/html documents with the extension. html.

? Ignore-length ignore the 'content-length' header field

? Header = STRING insert STRING in headers

? Proxy-user = USER: Set the proxy username to USER.

? Proxy-passwd = PASS: Set the proxy password to PASS

? Referer = the URL contains the 'referer' header in the HTTP request.

-S ,? Save-headers: save the HTTP header to the file

-U ,? User-agent = set the AGENT name to AGENT instead of Wget/VERSION.

? No-http-keep-alive closes the HTTP activity link (permanent link ).

? Cookies = off do not use cookies.

? Load-cookies = FILE loads cookies from the FILE before starting the session

? Save-cookies = FILE save cookies to the FILE after the session ends

* FTP options

-Nr ,? Dont-remove-listing: Do not remove the '. listing' file.

-G ,? Glob = on/off enable or disable the globbing mechanism of file names

? Passive-ftp uses passive transmission mode (default ).

? Active-ftp active transmission mode

? Retr-symlinks recursively points the link to a file instead of a directory)

* Recursive download

-R ,? Recursive download-use it with caution!

-L ,? Level = maximum NUMBER recursive depth (inf or 0 represents infinity ).

? Delete-after the file is partially deleted

-K ,? Convert-links converts non-relative links to relative links

-K ,? Backup-converted backs up file X to X. orig before converting file X

-M ,? Mirror is equivalent to-r-N-l inf-nr.

-P ,? Page-requisites download and display all images of HTML files

* Recursive download contains and does not contain (accept/reject)

-,? Accept = LIST of accepted extensions separated by semicolons

-R ,? Reject = LIST of unaccepted extensions separated by semicolons

-D ,? Domains = LIST of accepted domains separated by semicolons

? Exclude-domains = LIST a semicolon-separated LIST of unacceptable domains

? Follow-ftp tracking FTP links in HTML documents

? Follow-tags = LIST a semicolon-separated LIST of HTML tags to be tracked

-G ,? Ignore-tags = LIST the LIST of ignored HTML tags separated by semicolons

-H ,? Span-hosts is recursively transferred to the external host

-L ,? Relative only traces relative links

-I ,? Include-directories = LIST of allowed directories

-X ,? Exclude-directories = LIST of excluded directories

-Np ,? No-parent should not be traced back to parent directory

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.