Loading

44、wget和curl的常用参数


1、wget:

wget是文件下载的工具;

不加任何参数是直接下载该文件;

(1)-O:

将下载的文件指定为特定的文件名;

wget -O baidu.html www.baidu.com

--2019-04-01 23:11:52-- http://www.baidu.com/

正在解析主机 www.baidu.com (www.baidu.com)... 183.232.231.174, 183.232.231.172

正在连接 www.baidu.com (www.baidu.com)|183.232.231.174|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 200 OK

长度:2381 (2.3K) [text/html]

正在保存至: “baidu.html”


100%[======================================================================================================>] 2,381 --.-K/s 用时 0s


2019-04-01 23:11:52 (161 MB/s) - 已保存 “baidu.html” [2381/2381])

(2)-o:

将输出的信息(即上面'(1)'中的输出信息)写人到指定的文件并将下载的内容下载到本地;

wget -o baidu.info www.baidu.com

(3)-c:

断点续传;

--progress=TYPE #选择进度条的类型;

(4)-S:

打印服务响应,并下载文件;

--spider #不下载任何文件;

(5)-T:

超时的秒数;

(6)-t:

重试次数;

2、curl:

curl是文件下载工具;

不加任何参数是直接在屏幕上输出该文件的内容;

(1)-C #断点续转;

(2)-D #把header信息写入到该文件中;

(3)-f #连接失败时不显示http错误,而是返回错误的http代码;

curl -f www.baidu.com

(3)-o #另存为;

curl -o baidu-index.html www.baidu.com/index.html

(4)-O #下载文件;

curl -O www.baidu.com/index.html

(5)-s #静音模式,下载时不输出进度信息;

curl -O www.baidu.com/index.html

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 2381 100 2381 0 0 27154 0 --:--:-- --:--:-- --:--:-- 27367

curl -Os www.baidu.com/index.html

(6)-# #进度条显示当前的传送状态;

3、weget和cul的区别:

虽然wget和curl都是下载工具,但是curl更偏向于文件内容在屏幕上的打印;

posted @ 2020-02-15 21:10  云起时。  阅读(203)  评论(0编辑  收藏  举报