此 Curl 備忘清單包含命令和一些常見(jiàn)的 Curl 技巧示例。
Curl 是一種在服務(wù)器之間傳輸數(shù)據(jù)的工具,支持協(xié)議,包括 HTTP/FTP/IMAP/LDAP/POP3/SCP/SFTP/SMB/SMTP 等
-o <file> # --output: 寫入文件
-u user:pass # --user: 驗(yàn)證
-v # --verbose: 在操作期間使 curl 冗長(zhǎng)
-vv # 更冗長(zhǎng)
-s # --silent: 不顯示進(jìn)度表或錯(cuò)誤
-S # --show-error: 與 --silent (-sS) 一起使用時(shí),顯示錯(cuò)誤但沒(méi)有進(jìn)度表
-i # --include: 在輸出中包含 HTTP 標(biāo)頭
-I # --head: 僅標(biāo)頭
-X POST # --request
-L # 如果頁(yè)面重定向,請(qǐng)點(diǎn)擊鏈接
-F # --form: multipart/form-data 的 HTTP POST 數(shù)據(jù)
# --data: HTTP post 數(shù)據(jù)
# URL 編碼(例如,status="Hello")
-d 'data'
# --data 通過(guò)文件
-d @file
# --get: 通過(guò) get 發(fā)送 -d 數(shù)據(jù)
-G
-A <str> # --user-agent
-b name=val # --cookie
-b FILE # --cookie
-H "X-Foo: y" # --header
--compressed # 使用 deflate/gzip
--cacert <file>
--capath <dir>
-E, --cert <cert> # --cert: 客戶端證書文件
--cert-type # der/pem/eng
-k, --insecure # 對(duì)于自簽名證書
apk add --update curl # alpine linux 中安裝
| 命令 | 說(shuō)明 |
|---|---|
curl -I https://www.baidu.com | curl 發(fā)請(qǐng)求 |
curl -v -I https://www.baidu.com | 帶有詳細(xì)信息的 curl 發(fā)請(qǐng)求 |
curl -X GET https://www.baidu.com | 使用顯式 http 方法進(jìn)行 curl |
curl --noproxy 127.0.0.1 http://www.stackoverflow.com | 沒(méi)有 http 代理的 curl |
curl --connect-timeout 10 -I -k https://www.baidu.com | curl 默認(rèn)沒(méi)有超時(shí) |
curl --verbose --header "Host: www.mytest.com:8182" www.baidu.com | curl 得到額外的標(biāo)題 |
curl -k -v https://www.google.com | curl 獲取帶有標(biāo)題的響應(yīng) |
$ curl -v -include \
--form key1=value1 \
--form upload=@localfilename URL
$ curl -XGET http://${elasticsearch_ip}:9200/_cluster/nodes | python -m json.tool
| 命令 | 說(shuō)明 |
|---|---|
curl -d "name=username&password=123456" <URL> | curl 發(fā)請(qǐng)求 |
curl <URL> -H "content-type: application/json" -d "{ \"woof\": \"bark\"}" | curl 發(fā)送 json |
curl -sSL https://get.rvm.io | bash
| 命令 | 說(shuō)明 |
|---|---|
curl -L -s http://ipecho.net/plain, curl -L -s http://whatismijnip.nl | 獲取我的公共 IP |
curl -u $username:$password http://repo.dennyzhang.com/README.txt | 帶憑證的 curl |
curl -v -F key1=value1 -F upload=@localfilename <URL> | curl 上傳 |
curl -k -v --http2 https://www.google.com/ | 使用 http2 curl |
curl -T cryptopp552.zip -u test:test ftp://10.32.99.187/ | curl ftp 上傳 |
curl -u test:test ftp://10.32.99.187/cryptopp552.zip -o cryptopp552.zip | curl ftp 下載 |
curl -v -u admin:admin123 --upload-file package1.zip http://mysever:8081/dir/package1.zip | 使用憑證 curl 上傳 |
curl -s -w \
'\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nAppCon time:\t%{time_appconnect}\nRedirect time:\t%{time_redirect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' \
-o /dev/null https://www.google.com
curl -o /dev/null --silent -Iw "%{http_code}" https://example.com/my.remote.tarball.gz
curl https://example.com | \
grep --only-matching 'src="[^"]*.[png]"' | \
cut -d\" -f2 | \
while read i; do curl https://example.com/"${i}" \
-o "${i##*/}"; done
從站點(diǎn)下載所有 PNG 文件(使用GNU grep)
curl --remote-name "https://example.com/linux-distro.iso"
重命名文件
curl --remote-name "http://example.com/index.html" --output foo.html
curl --remote-name --continue-at - "https://example.com/linux-distro.iso"
curl "https://www.{example,w3,iana}.org/index.html" --output "file_#1.html"
curl "https://{foo,bar}.com/file_[1-4].webp" --output "#1_#2.webp"
下載一系列文件(輸出foo_file1.webp、foo_file2.webp…bar_file1_webp等)
$ curl http://url/file > file
$ curl --user username:password http://example.com/
$ curl -u username:password http://example.com/
$ curl -o file http://url/file
$ curl --output file http://url/file
$ curl -I url
# 顯示頭信息
$ curl -o file http://url/file
$ curl --output file http://url/file
$ curl -s http://url/myscript.sh
curl -K file
# 從文件中讀取配置
curl --config file
$HOME/.curlrc # 類 UNIX 系統(tǒng)中的默認(rèn)配置文件
感谢您访问我们的网站,您可能还对以下资源感兴趣:
国产成人精品999视频&日本一区二区亚洲人妻精品&久久久精品国产99久久精&99热这里只有成人精品国产&精品国产剧情av一区二区&成人亚洲精品久久久久app&国产精品美女高潮抽搐A片