-s, —slient
沉默模式, 不顯示具體的過程, 看一下有沒有這個(gè)參數(shù)的區(qū)別
xyz@mac:~ > curl -o /dev/null www.baidu.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 96551 0 96551 0 0 58649 0 --:--:-- 0:00:01 --:--:-- 58657
xyz@mac:~ > curl -o /dev/null -s www.baidu.com
xyz@mac:~ >
-w, --write-out <format>
例如我要獲取返回遠(yuǎn)程網(wǎng)站的狀態(tài)碼以及ip可以這么獲取
curl -o /dev/null -s -w %{http_code}:%{remote_ip} www.baidu.com
-m, --max-time <seconds>
Maximum time in seconds that you allow the whole operation to take. 設(shè)置超時(shí)時(shí)間
> curl www.google.com.hk -m 1
curl: (28) Connection timed out after 1003 milliseconds
-x, --proxy <[protocol://][user:password@]proxyhost[:port]>
Use the specified proxy. 使用代理
-i, --include
(HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...
獲取的內(nèi)容包括響應(yīng)頭
-I, --head
(HTTP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on an FTP or FILE file, curl dis-
plays the file size and last modification time only.
只獲取http響應(yīng)頭, 使用http的HEAD方法請(qǐng)求
curl -x 127.0.0.1:8888 -I www.baidu.com
-L, --location
自動(dòng)跳轉(zhuǎn)
curl -I -L baidu.com/a
-v, --verbose
獲取通信的詳細(xì)過程
--trace <file>
更詳細(xì)的請(qǐng)求信息:
-d, --data <data>
使用post發(fā)送請(qǐng)求信息
--data-urlencode <data>
對(duì)data數(shù)據(jù)進(jìn)行編碼
curl -x 127.0.0.1:8888 --data "q=apple" http://dict.youdao.com/search
-X, --request <command>
使用不同的請(qǐng)求方式, 例如使用post方式請(qǐng)求baidu
curl -X POST www.baidu.com
-F, --form <name=content>
上傳文件
如果是文件
-F, --form <name=content>
curl -x 127.0.0.1:8888 -F "web=@output.txt;type=text/html" -F name=xyz url.com
—header, —referer, —cookie, —user-agent 都看字面意思就知道作用了