CURL访问url显示响应时间

时间:2023-03-09 15:32:40
CURL访问url显示响应时间

  

curl -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total}   http://www.baidu.com

时间指标解释 :

time_connect    建立到服务器的 TCP 连接所用的时间

time_starttransfer    在发出请求之后,Web 服务器返回数据的第一个字节所用的时间

The time, in seconds, it took from the start
until the first byte was just about to be trans-
ferred. This includes time_pretransfer and also
the time the server needed to calculate the
result

time_total   完成请求所用的时间

在 发出请求之后,Web 服务器处理请求并开始发回数据所用的时间是

(time_starttransfer)1.044 - (time_connect)0.244 = 0.8 秒

客户机从服务器下载数据所用的时间是

(time_total)2.672 - (time_starttransfer)1.044 = 1.682 秒

指定特定主机IP地址访问网站

curl -x 58.214.7.150:80 http://www.baidu.com

curl -x 58.214.7.150:80 http://www.baidu.com

curl用法大全

-x 指定访问IP与端口号

curl -x 192.168.1.1:80  http://www.miotour.com

-I 仅仅取文件的http头部

curl   -I  -x 192.168.1.1:80  http://www.miotour.com

用referer做的防盗链,就可以使用-e来设置

curl -e “http://www.qiecuo.org”    http:// www.miotour.com -v  -I

-H去构造你想要的http头部

curl -H “X-Forward-For:8.8.8.8″ http://www.miotour.com  -v  -I

curl反馈时间,例如连接时间,下载时间等信息

curl -w %{time_connect}:%{time_starttransfer}:%{time_total} -s -o /dev/null

将一个文件保存到硬盘上,命名为file.html

curl -o file.html  http://www.miotour.com/index.html

下载index.html文件, -O是大写的字母

curl -O http://www.miotour.com/index.html

curl提交用户名和密码

curl http://name:passwd@www.miotour.com
curl -u name:passwd http://www.miotour.com

-b “cookie” 此参数用来构造一个携带cookie的请求