此 Curl 备忘清单包含命令和一些常见的 Curl 技巧示例。
Curl 是一种在服务器之间传输数据的工具,支持协议,包括 HTTP/FTP/IMAP/LDAP/POP3/SCP/SFTP/SMB/SMTP 等
| 命令 | 说明 |
|---|---|
curl -I https://www.baidu.com | curl 发请求 |
curl -v -I https://www.baidu.com | 带有详细信息的 curl 发请求 |
curl -X GET https://www.baidu.com | 使用显式 http 方法进行 curl |
curl --noproxy 127.0.0.1 http://www.stackoverflow.com | 没有 http 代理的 curl |
curl --connect-timeout 10 -I -k https://www.baidu.com | curl 默认没有超时 |
curl --verbose --header "Host: www.mytest.com:8182" www.baidu.com | curl 得到额外的标题 |
curl -k -v https://www.google.com | curl 获取带有标题的响应 |
| 命令 | 说明 |
|---|---|
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