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的話就是下面的情況,這是在腳本等情況下不需要的信息。
監控首頁各項時間指標:
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的請求