wget命令及特点

来源:互联网 发布:java继承实例 编辑:程序博客网 时间:2024/05/16 03:33

wget命令及特点

全称GNU Wget 意为WordWideWeb+Get

Wget vs cURL

常用的两种工具主要区别1

cURL Wget liburl库跨平台支持 仅命令行 pipe命令,如curl -L git.io/cow | bash 不支持 支持FTP, FTPS, Gopher, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, POP3, IMAP, SMB/CIFS, SMTP, RTMP and RTSP 仅支持HTTP/HTTPS,FTP 加入变量支持批量下载,双向传输,压缩等 支持递归下载,断点续传 默认命令只传输数据,通过各种选项指定各类功能 默认支持cookie,redirect-following,time stamping,仅左手即可完成键盘操作…

对比结果

wget是专职的下载利器,简单,专一,极致;curl可以下载,但是长项不在于下载,而在于模拟提交web数据,POST/GET请求,调试网页,等等。

在下载上,wget可以递归,支持断点;而curl支持URL中加入变量,因此可以批量下载。用wget来下载文件,加 -c选项不怕断网;使用curl 来跟网站的API 交互,简便清晰。

下载命令

官方链接,忒多… 以下参考部分网站23,列举部分常用命令

下载

wget http://www.example.org/testfile.zip

保存文件名

wget -O myfile http://www.example.org/testfile.zip

断点续传

wget -c http://www.example.org/testfile.zip

下载指定格式

wget -r -A.pdf http://www.example.org/

-r 递归下载全站

伪装浏览器

wget --user-agent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16" http://www.example.org/testfile.zip

从list里下载多个文件

wget -i downloadlist.txt

指定日志输出

wget -o download.log http://www.example.org/testfile.zip

使用ftp下载

wget --ftp-user=USERNAME --ftp-password=PASSWORD http://www.example.org

断点续传

wget -c ftp://www.example.org/testfile.zip

限制速度

wget --limit-rate=200k http://www.example.org/files/archive.zip

后台下载

wget -b http://www.example.org/files/archive.zip

下载整个镜像

wget --mirror -p --convert-links -P /tmp/mirror --reject=html http://www.example.org

wget可以下载整个网站到本地,同时遵循robots协议。
–miror:开户镜像下载
-p:下载所有为了html页面显示正常的文件
–convert-links:下载后,转换成本地的链接
-P ./LOCAL:保存所有文件和目录到本地指定目录
–reject=gif :拒绝下载gif

检测网站链接

wget --spider http://www.example.org/testfile.zip

参考资料


  1. cURLvs.Wget ↩
  2. wget commands ↩
  3. wget 命令 from csdn ↩
原创粉丝点击