1、开启gzip请求
curl -I http://www.sina.com.cn/ -H Accept-Encoding:gzip,defalte

2、监控网页的响应时间
curl
-o /dev/null -s -w "time_connect: %{time_connect}\ntime_starttransfer:
%{time_starttransfer}\ntime_total: %{time_total}\n"
"http://www.kklinux.com"

3. 监控站点可用性
curl -o /dev/null -s -w %{http_code} "http://www.kklinux.com"

4、以http1.0协议请求(默认为http1.1)
curl -0 ..............

监控站点首页下载时间:

curl -o /dev/null -s -w ‘%{time_total}’ http://www.miotour.com

curl -o /dev/null -s -w ‘%{http_code}’ http://www.miotour.com

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

结果:2.547

-s 静默输出;没有-s的话就是下面的情况,这是在脚本等情况下不需要的信息。

[ec2-user@ip-10-122-250-19 ~]$ curl -o /dev/null  -w ‘%{time_total}’ http://www.miotour.com
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100 67770    0 67770    0     0  19228      0 –:–:–  0:00:03 –:–:– 20705
结果:3.524

监控首页各项时间指标:

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

结果:                                                0.244:                             1.044:                         2.672

时间指标解释 :

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

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

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 61.135.169.105:80 http://www.baidu.com

curl -x 61.135.169.125: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的请求

curl获取响应时间的更多相关文章

  1. 使用 cURL 获取站点的各类响应时间 – dns解析时间,响应时间,传输时间

    http://zhangrenfang8738.blog.163.com/blog/static/95401881201142711450245/ curl监控站点响应时间 2011-05-27 11 ...

  2. php curl获取的数据不直接输出

    curl获取页面内容,不直接输出到页面 必需设置curl的CURLOPT_RETURNTRANSFER选项为1或true curl_setopt($ch, CURLOPT_RETURNTRANSFER ...

  3. PHP curl获取页面内容,不直接输出到页面,CURLOPT_RETURNTRANSFER参数设置

    使用PHP curl获取页面内容或提交数据,有时候希望返回的内容作为变量储存,而不是直接输出.这个时候就必需设置curl的或true. 1.curl获取页面内容, 直接输出例子: <?php $ ...

  4. 使用curl获取Location:重定向后url

    在php获取http头部信息上,php有个自带的函数get_headers(),我以前也是用这个的,听说效率在win上不咋地,再加上最近研究百度url无果,写了cURL获取重定向url的php代码来折 ...

  5. curl获取http请求的状态码

    $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); //设置头文件的信息作为数据流输出 curl_setopt($curl, CUR ...

  6. php 原生或curl获取 http headers

    有一个函数: array get_headers ( string $url [, int $format = 0 ] ) Parameters url The target URL. format ...

  7. 使用curl获取乱码问题

    今天通过curl获取百度地图接口数据,获取到居然是乱码,于是我查看是不是编码问题,发现返回的编码和自己的编码都是utf-8, 继续找原因,发现header报文中  Content-encoding 为 ...

  8. php 通过curl获取远程数据,返回的是一个数组型的字符串,高手帮忙如何将这个数组类型的字符串变成数组。

    如 Array([0] => Array([0] => Array([kd_status] => 已签收[kd_time] => 2014-04-30 18:59:43 [b] ...

  9. PHP CURL获取页面内容输出例子

    使用PHP curl获取页面内容或提交数据,有时候希望返回的内容作为变量储存,而不是直接输出.这个时候就必需设置curl的CURLOPT_RETURNTRANSFER选项为1或true. 1.curl ...

随机推荐

  1. EVEREST Ultimate Edition 5.50 正式版 序列号

    EVEREST Ultimate Edition 5.50 正式版 序列号 EVEREST 5.5 Final 序列号 注册码 搜集到的EVEREST最新的5.5版本的序列号 序列号: C4J1IPH ...

  2. spring boot: 输出json

    spring boot:  输出json 注意:关闭java的Terminate后,在重新启动,否则报错 app.java启动配置 package com.muyang.boot1; import o ...

  3. Android之微信开放平台实现分享(分享好友和朋友圈)

    开发中分享操作往往经常遇到,而且还是一些比较大型一定的平台,如微信,QQ,微博等.写这篇博客主要是把微信的的分享和相关操作表达一下,分享可以包含:文字,视频,音乐,图片等分享. 分享可以有 分享给好友 ...

  4. maven 工程mybatis自动生成实体类

    generatorConfig.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ge ...

  5. HDU 4633 Who's Aunt Zhang ★(Polya定理 + 除法取模)

    题意 用K个颜色给魔方染色,魔方只能整体旋转并且旋转重合的方案算一种,求一共有多少不同的染色方案. 思路 经典的Polya应用,记住正六面体的置换群就可以了,魔方就是每个大面变成9个小面了而已: 本题 ...

  6. sgu 146. The Runner 取模技巧 难度:1

    146. The Runner time limit per test: 0.25 sec.memory limit per test: 4096 KB input: standard inputou ...

  7. Python3 字符串(七)

    字符串是 Python 中最常用的数据类型.我们可以使用引号( ' 或 " )来创建字符串. 创建字符串很简单,只要为变量分配一个值即可. python中单引号和双引号使用完全相同. 使用三 ...

  8. New Concept English Two 18 46

    $课文44  穿过森林 451. Mrs. Anne Sterling did not think of the risk she was taking when she ran through a ...

  9. 1月中旬值得一读的10本技术新书(机器学习、Java、大数据等)!

    1月中旬,阿里云云栖社区 联合 博文视点 为大家带来十本技术书籍(机器学习.Java.大数据等).以下为书籍详情,文末还有福利哦! 书籍名称:Oracle数据库问题解决方案和故障排除手册 内容简介 & ...

  10. It is the courage

    It is the reality that a society which becomes lower and becomes weak.Believe it or not,I think it i ...