curl 的用法指南

curl 是命令行界面下的浏览器。

大写-I ,向服务器发出 HEAD 请求,然会将服务器返回的 HTTP 标头打印出来。

root@ubuntu:~/shou# curl -I www.baidu.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: keep-alive
Content-Length: 277
Content-Type: text/html
Date: Mon, 12 Oct 2020 03:40:16 GMT
Etag: "575e1f60-115"
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18


大写-O选项,将服务器回应保存成文件,并将 URL 的最后部分当作文件名。

root@ubuntu:~/shou# curl -O http://www.baidu.com/index.html && ls
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2381  100  2381    0     0  46504      0 --:--:-- --:--:-- --:--:-- 46686
index.html

 -s参数将不输出错误和进度信息。

root@ubuntu:~/shou# curl  file:///root/shou/qqq.sh |sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    15  100    15    0     0   443k      0 --:--:-- --:--:-- --:--:--  443k
123456789
root@ubuntu:~/shou# curl -s file:///root/shou/qqq.sh |sh
123456789

-C- 参数支持断点续传

curl -C- -O http://127.0.0.1:80/mnt/workdir2/store/cdfy/2020/10/10/ce6d4b478c74a80c9d216f56f579ac49-CH1-H0000.mp4
** Resuming transfer from byte position 69390336
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  570M    0 1829k    0     0   147k      0  1:06:16  0:00:12  1:06:04  202k

-# 使用#显示传输进度

root@ubuntu:~/shou# curl -# -C - -O http://127.0.0.1:80/mnt/workdir2/store/cdfy/2020/10/10/ce6d4b478c74a80c9d216f56f579ac49-CH1-H0000.mp4
#######                                                                   11.0%

-v  输出通信的整个过程,用于调试 

root@ubuntu:~/shou# curl -v www.baidu.com
* Rebuilt URL to: www.baidu.com/
*   Trying 220.181.38.149...
* Connected to www.baidu.com (220.181.38.149) port 80 (#0)
> GET / HTTP/1.1
> Host: www.baidu.com
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: keep-alive
< Content-Length: 2381
< Content-Type: text/html
< Date: Mon, 12 Oct 2020 05:32:10 GMT
< Etag: "588604c8-94d"
< Last-Modified: Mon, 23 Jan 2017 13:27:36 GMT
< Pragma: no-cache
< Server: bfe/1.0.8.18
< Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
<
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,......

 

 

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值