What is wget
? ? Wget in the original help in English speaking is: the Non-interactive network downloader, non-interactive Web downloader. It supports protocols such as HTTP, HTTPS, FTP, and also supports HTTP proxy-based downloads. Other key features are as follows:
 
 
  
  - Can work in the background without having to log on to the system
  
  - You can track HTML, XHTML, CSS, and other files to download the pages on the server to a local for offline browsing.
  
  - Support for downloads and connections under slow and unstable networks.
  
 
 
Common syntax
wget [选项] [URL]
The common options parameters are as follows:
 
 
  
   
   | Options |  
   Description |  
  
 
  
  
   
   | -V,--version |  
   Display version Information |  
  
 
   
   | -H,--Help |  
   Display Help information |  
  
 
   
   | -B,--Backgroup |  
   Run in the form of a later stage |  
  
 
   
   | -e command,--execute command |  
   If the command belongs to. WGETRC, execute the command |  
  
 
   
   | -O logfile,--output-file=logfile |  
   Print the log to a file |  
  
 
   
   | -A logfile,--append-output=logfile |  
   Append log to File |  
  
 
   
   | -Q,--Quiet |  
   Silent mode, turn off wget output information |  
  
 
   
   | -V,--verbose |  
   Show detailed information, wget default mode |  
  
 
   
   | -I. File,--inpu-file=file |  
   To read a URL from a file |  
  
 
   
   | -B URL,--Base=url |  
   Set the relative URL address of the connection |  
  
 
   
   | --bind-address=address |  
   Set the IP address or host name of the connection |  
  
 
   
   | -T number,--Tries=number |  
   Set the number of retries, 0 and INF are always retried, the default value is 20 |  
  
 
   
   | -O file,--output-document=file |  
   Save the contents of the download file to a local file |  
  
 
   
   | -NC,--No-clobber |  
   If the download file already exists, it is not downloaded |  
  
 
   
   | -C,--Continue |  
   Continue with the last download task |  
  
 
   
   | -N,--timestamping |  
   Add Time stamp |  
  
 
   
   | -S,--server-response |  
   Print HTTP, FTP header information |  
  
 
   
   | -T seconds,--timeout=seconds |  
   Setting the time-out period |  
  
 
   
   | --limit-rate=amount |  
   Limit download speed |  
  
 
   
   | -X |  
   Set Download exclusions |  
  
 
   
   | -R,--Recursive |  
   Recursive download files |  
  
 
   
   | -NH,--no-host-directories |  
   Prohibit creating a folder with a domain name command |  
  
 
   
   | --cut-dirs=number |  
   Ignore hierarchy directory in |  
  
 
  
Configuration file
? ? If you want to use the wget command, or first understand some of the hidden rules wget, location in:
 
 
  
  - /etc/wgetrc
  
  - In the home directory. WGETRC
  
 
 
1, wget command some options can be separated by commas, such as-X can set exclusions, if only once, it does not matter, but if you do not need to download these directories for a long time, you can add these exclusions. WGETRC in the configuration file
exclude_directories=test,tmp,temp
2, in the first case, suddenly want to download these files, you can remove the configuration file settings, you can also use the following methods:
wget -r -X ‘‘ ftp://192.168.8.8
Common examples
1. Download the file:
[[email protected] ]# wget https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_redBlue_32fe2c69.png--2018-07-28 19:55:17--  https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_redBlue_32fe2c69.png正在解析主机 ss0.bdstatic.com (ss0.bdstatic.com)... 180.163.198.32正在连接 ss0.bdstatic.com (ss0.bdstatic.com)|180.163.198.32|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:8618 (8.4K) [image/png]正在保存至: “logo_redBlue_32fe2c69.png”100%[=============================================================================================================================>] 8,618       --.-K/s 用时 0.002s2018-07-28 19:55:17 (3.80 MB/s) - 已保存 “logo_redBlue_32fe2c69.png” [8618/8618])
2. Download directory and background execution
[[email protected] test]# wget -r -b https://mirrors.aliyun.com/centos/7.5.1804/atomic/x86_64/adb/继续在后台运行,pid 为 26252。将把输出写入至 “wget-log”。[[email protected] test]# ll总用量 4drwxr-xr-x 3 root root   38 7月  28 20:14 mirrors.aliyun.com-rw-r--r-- 1 root root 1257 7月  28 20:14 wget-log[[email protected] test]# cat wget-log --2018-07-28 20:14:11--  https://mirrors.aliyun.com/centos/7.5.1804/atomic/x86_64/adb/正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 180.163.155.11, 180.163.155.8, 180.163.155.9, ...正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|180.163.155.11|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:3518 (3.4K) [text/html]正在保存至: “mirrors.aliyun.com/centos/7.5.1804/atomic/x86_64/adb/index.html”
3. Prohibit multi-level directories in the build
[[email protected] test]# wget -b -r -nH --cut-dir=6 https://mirrors.aliyun.com/centos/7.5.1804/atomic/x86_64/adb/继续在后台运行,pid 为 34849。将把输出写入至 “wget-log”。[[email protected] test]# ll总用量 12-rw-r--r-- 1 root root 3518 7月  28 20:25 index.html-rw-r--r-- 1 root root  295 10月 31 2017 robots.txt-rw-r--r-- 1 root root 1113 7月  28 20:25 wget-log
The download directory path is as follows:
 
 
  
   
   | situation |  
   Results |  
  
 
  
  
   
   | -R |  
   mirrors.aliyun.com/centos/7.5.1804/atomic/x86_64/adb/ |  
  
 
   
   | -nh |  
   centos/7.5.1804/atomic/x86_64/adb/ |  
  
 
   
   | -nh--cut-dir=1 |  
   centos/7.5.1804/atomic/x86_64/adb/ |  
  
 
   
   | -nh--cut-dir=4 |  
   CD/ |  
  
 
   
   | -nh--cut-dir=6 |  
   . |  
  
 
  
 4. Save the downloaded file to a local file 
 
[[email protected] test]# wget-t 2-o log.txt https://mirrors.aliyun.com/centos/7.5.1804/isos/x86_64/ Sha256sum.txt-o test.txt[[email protected] test]# ll total dosage 8-rw-r--r--1 root root 554 July 20:37 log.txt-rw-r--r-- 1 root root 598 May 03:59 test.txt[[email protected] test]# cat log.txt--2018-07-28 20:37:28--https://mirrors.al Iyun.com/centos/7.5.1804/isos/x86_64/sha256sum.txt parsing host mirrors.aliyun.com (mirrors.aliyun.com) ... 180.163.155.9, 180.163.155.10, 180.163.155.11, ... Connecting mirrors.aliyun.com (mirrors.aliyun.com) |180.163.155.9|:443 ... is connected. An HTTP request has been made and is waiting for a response ... $ OK Length: 598 [Text/plain] saving to: "Test.txt" 0K 100% 175m=0s2018-07-28 20:37:28 (175 MB/s)-Saved "Te St.txt "[598/598]) [[email protected] test]# Cat test.txt506e4e06abf778c3435b4e5745df13e79ebfc86565d7ea1e128067ef6b5a6345 centos-7-x86_64- Dvd-1804.isob346daae2a93caed88e822e722e7284c648f9919d475ff98489b424350f99a45 CentOS-7-x86_64- livegnome-1804.iso040ddfb27d30e48efad8709c9df946202cec169077c843fd2cbe8d802187ff8e centos-7-x86_64- LIVEKDE-1804.ISO714ACC0AEFB32B7D51B515E25546835E55A90DA9FB00417FBEE2D03A62801EFD CentOS-7-x86_64- minimal-1804.iso99723c8b87dcec21df8aed23de1eb810346d42cfd2a3fafafe70a68296053417 CentOS-7-x86_64- EVERYTHING-1804.ISO937BF0A7B0932817F84F7230F15ED88911BBBD85C0C958680792B7F8D8F9C1A9 CentOS-7-x86_64- Netinstall-1804.iso
This article is posted on the subscription number, such as your friends like my article, you can also follow my subscription number: Woaitest, or scan the following QR code to add attention:
Linux Essentials Tutorial 38-File Download