curl -w "\n" https://www.seekerhcl.cn/
curl --interface eth0 ip.sb
或
curl --int 192.168.0.10 ip.sb (此处IP是网卡对应IP地址)
curl -o /dev/null -s -w %{http_code}::%{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" https://www.seekerhcl.cn/
-o:把curl 返回的html、js 输出至回收站[ /dev/null]
-s:去掉所有状态
-w:按照后面的格式写出rt
--connect-timeout:指定tcp连接超时时间
-m:指定数据传输超时时间
http_code:状态码
time_namelookup:DNS 解析域名www.seekerhcl.cn的时间,单位为秒,如果测试的地址为IP,这里耗时即为0
time_commect:client 和 server 端建立 TCP 连接的时间
time_starttransfer:从 client 发出请求;到 web server 响应第一个字节的时间
time_total:client 发出请求;到 web server 发送回所有的相应数据的时间
speed_download:下载速度,单位 byte/s
shell> cat curl.format
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
time_total: %{time_total}\n
shell> curl -so /dev/null -w @curl.format https://www.seekerhcl.cn/
time_namelookup: 0.004029
time_connect: 0.014525
time_appconnect: 0.048664
time_pretransfer: 0.048708
time_redirect: 0.000000
time_starttransfer: 0.060849
time_total: 0.060921
-d 等价 --data
GET:
curl https://www.seekerhcl.cn/
POST:
curl -X POST --data 'keyword=test' https://www.seekerhcl.cn/
curl -X POST --data '{"message": "one"}' https://www.seekerhcl.cn/
GET方式,不加参数默认为GET方式
curl -Iv -X GET https://www.seekerhcl.cn/
HEAD方式, 参数 -X HEAD
curl -Iv -X HEAD https://www.seekerhcl.cn/
#弊端是仅限于访问http站点
curl -IvL http://test.seekerhcl.cn -x 123.206.14.147:80
#弊端是仅限于访问http站点
curl -IvL http://123.206.14.147 -H 'Host:test.seekerhcl.cn'
# --resolve 参数格式
# --resolve <host:port:address[,address]...>
curl -IL --resolve test.seekerhcl.cn:443:123.206.14.147 https://test.seekerhcl.cn