wget是在Linux下开发的开放源代码的软件,作者是Hrvoje Niksic,后来被移植到包括Windows在内的各个平台上。它有以下功能和特点:
(1)支持断点下传功能;这曾是网络蚂蚁和FlashGet当年最大的卖点,现在,Wget也可以使用此功能,那些网络不是太好的用户可以放心了;
(2)同时支持FTP和HTTP下载方式;尽管现在大部分软件可以使用HTTP方式下载,但是,有些时候,仍然需要使用FTP方式下载软件;
(3)支持代理服务器;对安全强度很高的系统而言,一般不会将自己的系统直接暴露在互联网上,所以,支持代理是下载软件必须有的功能;
(4)设置方便简单;可能,习惯图形界面的用户已经不是太习惯命令行了,但是,命令行在设置上其实有更多的优点,最少,鼠标可以少点很多次,也不要担心是否错点鼠标;
(5)程序小,完全免费;程序小可以考虑不计,因为现在的硬盘实在太大了;完全免费就不得不考虑了,即使网络上有很多所谓的免费软件,但是,这些软件的广告却不是我们喜欢的;

wget虽然功能强大,但是使用起来还是比较简单的,更多用法请见:wget 命令用法详解linux wget 命令用法详解

 

GNU Wget is a free software package for retrieving files using HTTP, HTTPS, FTP and FTPS, the most widely used Internet protocols. It is a non-interactive commandline tool, so it may easily be called from scripts, cron jobs, terminals without X-Windows support, etc.

GNU Wget has many features to make retrieving large files or mirroring entire web or FTP sites easy, including:

  • Can resume aborted downloads, using REST and RANGE
  • Can use filename wild cards and recursively mirror directories
  • NLS-based message files for many different languages
  • Optionally converts absolute links in downloaded documents to relative, so that downloaded documents may link to each other locally
  • Runs on most UNIX-like operating systems as well as Microsoft Windows
  • Supports HTTP proxies
  • Supports HTTP cookies
  • Supports persistent HTTP connections
  • Unattended / background operation
  • Uses local file timestamps to determine whether documents need to be re-downloaded when mirroring
  • GNU Wget is distributed under the GNU General Public License.

 

 

wget 官网https://www.gnu.org/software/wget/    ,wget历史版本

curl 官网https://curl.se/download.html  , curl 历史版本

下载最新版本:

wget-latest.tar.gz     (2024-03-10)

wget-1.24.5.tar.gz    (2024-03-10)

wget-1.14.tar.gz     (2012-08-05)

 

curl-8.8.0.tar.gz     (2024-05-22)

curl-7.54.0.tar.gz   (2017-04-19)

curl-7.29.0.tar.gz   (2013-02-06)

 

1、系统默认安装wget curl

1)下载最新 yum 源

# 1. 备份当前的yum源配置文件
sudo cp -r /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base__bk__20240612.repo
 
# 2. 下载新的CentOS官方yum源配置文件
# CentOS 7的yum源
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 或者使用wget命令
# sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
 
# 如果你使用的是CentOS 8,请替换上面的链接为对应的CentOS 8源
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

# 3. 清理yum缓存, 并生成新的缓存
sudo yum clean all
sudo yum makecache

# 4. 更新yum
sudo yum update -y

 

2)安装默认的 wget curl

yum install wget curl -y

# yum install wget curl -y
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration          
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.cloud.aliyuncs.com
 * extras: mirrors.cloud.aliyuncs.com
 * updates: mirrors.cloud.aliyuncs.com
Package wget-1.14-18.el7_6.1.x86_64 already installed and latest version
Package curl-7.29.0-59.el7_9.2.x86_64 already installed and latest version

 

2、自定义安装 wget curl  

1)自定义安装 wget

提前安装依赖库:

yum -y install gnutls gnutls-devel

编译安装openssl:CentOS 安装OpenSSL 支持 QUIC for http/3

下载安装 wget

wget https://ftp.gnu.org/gnu/wget/wget-1.24.5.tar.gz
tar zxvf wget-1.24.5.tar.gz
cd wget-1.24.5/ 
# ./configure --help        # 查看安装参数
# ./configure --help | grep -iEw "\-\-enable|\-\-with"  # 查看安装参数
# ./configure   或  # ./configure --with-openssl=/usr/local/openssl
make
make install

source /etc/profile     # 使新安装的wget生效, 即 /usr/local/bin/wget 排在第一
# ll /bin/wget
-rwxr-xr-x 1 root root 418776 May 16  2019 /bin/wget            # 默认wget
# ll /usr/bin/wget 
-rwxr-xr-x 1 root root 418776 May 16  2019 /usr/bin/wget        # 默认wget
# ll /usr/local/bin/wget 
-rwxr-xr-x 1 root root 2056992 Jul  2 08:35 /usr/local/bin/wget # 新安装wget
#
# wget --version        # 查看验证最新安装wget版本
GNU Wget 1.24.5 built on linux-gnu.

其中,make 预编译的各配置参数:

# make
......
configure: Summary of build options:

  Version:           1.24.5
  Host OS:           linux-gnu
  Install prefix:    /usr/local
  Compiler:          gcc -std=gnu11
  CFlags:                -I/usr/include/p11-kit-1   -DHAVE_LIBGNUTLS   -DNDEBUG -g -O2   
  LDFlags:           
  Libs:              -lpcre   -lnettle   -lgnutls   -lz   
  SSL:               gnutls
  Zlib:              yes
  PSL:               no
  PCRE:              yes, via libpcre
  Digest:            yes
  NTLM:              yes
  OPIE:              yes
  POSIX xattr:       yes
  Debugging:         yes
  Assertions:        no
  Valgrind:          Valgrind testing not enabled
  Metalink:          no
  Resolver:          libc, --bind-dns-address and --dns-servers not available
  GPGME:             no
  IRI:               no
  Fuzzing build:     no, 
  libproxy:          no

 

2)自定义安装 curl

提前安装依赖库:CentOS 安装OpenSSL 支持 QUIC for http/3

下载安装 curl

wget https://curl.se/download/curl-8.8.0.tar.gz
tar zxvf curl-8.8.0.tar.gz
cd curl-8.8.0/
# ./configure --help        # 查看安装参数
# ./configure --help | grep -iEw "\-\-enable|\-\-with"  # 查看安装参数
./configure --with-openssl=/usr/local/openssl           # 需提前安装openssl
make
make install

source /etc/profile     # 使新安装的wget生效, 即 /usr/local/bin/curl 排在第一
# ll /bin/curl
-rwxr-xr-x 1 root root 156664 Dec 14  2023 /bin/curl            # 默认curl
# ll /usr/bin/curl
-rwxr-xr-x 1 root root 156664 Dec 14  2023 /usr/bin/curl        # 默认curl
# ll /usr/local/bin/curl              
-rwxr-xr-x 1 root root 271208 Jul  2 10:26 /usr/local/bin/curl  # 新安装wget

#
# curl --version        # 查看验证最新安装wget版本
curl 8.8.0 (x86_64-pc-linux-gnu) libcurl/8.8.0 OpenSSL/3.3.1 zlib/1.2.7 OpenLDAP/2.4.44
Release-Date: 2024-05-22
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz NTLM SSL threadsafe TLS-SRP UnixSockets

其中,make 预编译的各配置参数:

configure: Configured to build curl/libcurl:

  Host setup:       x86_64-pc-linux-gnu
  Install prefix:   /usr/local
  Compiler:         gcc -std=gnu11
   CFLAGS:          -Werror-implicit-function-declaration -O2 -Wno-system-headers -pthread
   CPPFLAGS:        -isystem /usr/local/openssl/include
   LDFLAGS:         -L/usr/local/openssl/lib64
   LIBS:            -lssl -lcrypto -lssl -lcrypto -lldap -llber -lz

  curl version:     8.8.0
  SSL:              enabled (OpenSSL v3+)
  SSH:              no      (--with-{libssh,libssh2})
  zlib:             enabled
  brotli:           no      (--with-brotli)
  zstd:             no      (--with-zstd)
  GSS-API:          no      (--with-gssapi)
  GSASL:            no      (libgsasl not found)
  TLS-SRP:          enabled
  resolver:         POSIX threaded
  IPv6:             enabled
  Unix sockets:     enabled
  IDN:              no      (--with-{libidn2,winidn})
  Build docs:       enabled (--disable-docs)
  Build libcurl:    Shared=yes, Static=yes
  Built-in manual:  enabled
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  Code coverage:    disabled
  SSPI:             no      (--enable-sspi)
  ca cert bundle:   /etc/pki/tls/certs/ca-bundle.crt
  ca cert path:     no
  ca fallback:      no
  LDAP:             enabled (OpenLDAP)
  LDAPS:            enabled
  RTSP:             enabled
  RTMP:             no      (--with-librtmp)
  PSL:              no      (--with-libpsl)
  Alt-svc:          enabled (--disable-alt-svc)
  Headers API:      enabled (--disable-headers-api)
  HSTS:             enabled (--disable-hsts)
  HTTP1:            enabled (internal)
  HTTP2:            no      (--with-nghttp2)
  HTTP3:            no      (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-openssl-quic, --with-msh3)
  ECH:              no      (--enable-ech)
  WebSockets:       no      (--enable-websockets)
  Protocols:        DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS IPFS IPNS LDAP LDAPS MQTT POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP
  Features:         AsynchDNS HSTS HTTPS-proxy IPv6 Largefile NTLM SSL TLS-SRP UnixSockets alt-svc libz threadsafe

 

 

参考推荐:

wget和curl中使用代理

Shell curl 和 wget 使用代理IP

Linux抓取网页方式(curl+wget)

curl 查看 HTTP Header 响应头信息

Linux curl 命令模拟 POST/GET 请求

Linux命令学习

Linux 15个命令,大幅提高工作效率

运维人员常用软件总结

Shell 脚本的常用功能代码

CentOS 7.9 / 7.2 / 6.5 系统安装指引