本文共 2306 字,大约阅读时间需要 7 分钟。
cURL包含一个命令行工具curl和一个类库libcurl,能够以非交互的模式通过URL传输数据。1.
官网https://curl.haxx.se/
源代码https://github.com/curl/curl
最新版本:2016年9月发布的7.50.22.cURL支持多种主流的传输协议
3.cURL可以通过命令行或脚本执行
1) 常见参数:-V,--version
-v,--verbose ,显示详细信息(默认开启) -C ,断点续传 -s,--silent,安静模式 -A,--user-agent <代理> -d,--data <key=value>,HTTP POST上传数据2) 应用示例:
curl ftp://cool.haxx.se:21/etc/issue/readme.txt
curl ftp://cool.haxx.se:21/ curl -u username sftp://example.com/etc/issue curl http://username:passwd@machine.domain:port/full/path/to/file curl ftp://username:passwd@machine.domain:port/full/path/to/file curl sftp://username:passwd@machine.domain:port/full/path/to/file curl -u username:passwd http://machine.domain:port/full/path/to/file curl -u username:passwd ftp://machine.domain:port/full/path/to/file curl -u username:passwd sftp://machine.domain:port/full/path/to/file curl -u username: --key ~/.ssh/id_rsa scp://cool.haxx.se:22/etc/issue/readme.txt curl -u username: --key ~/.ssh/id_rsa sftp://cool.haxx.se:21/etc/issue/readme.txt curl -u username: --key ~/.ssh/id_rsa --pass a_private_key_password scp://cool.haxx.se:22/etc/issue/readme.txt curl -u username: --key ~/.ssh/id_rsa --pass a_private_key_password sftp://cool.haxx.se:21/etc/issue/readme.txt curl -o a_new_file_name ftp://cool.haxx.se:21/etc/issue/readme.txt ,小写字母o,给出本地文件名 curl -O ftp://cool.haxx.se:21/etc/issue/readme.txt ,大写字母O,本地文件名使用远程文件名 curl -0 http://machine.domain:port/full/path/to/file ,数字0,表示HTTP 1.0协议 等价于curl --http1.0 http://machine.domain:port/full/path/to/file curl --http1.1 http://machine.domain:port/full/path/to/file curl --http2 http://machine.domain:port/full/path/to/file curl -1 https://machine.domain:port/full/path/to/file ,数字1,表示tlsv1协议 curl --tlsv1.0 https://machine.domain:port/full/path/to/file curl --tlsv1.1 https://machine.domain:port/full/path/to/file curl --tlsv1.2 https://machine.domain:port/full/path/to/file curl -2 https://machine.domain:port/full/path/to/file ,数字2,表示sslv2协议 curl -3 https://machine.domain:port/full/path/to/file ,数字3,表示sslv3协议 curl -4 http://ipv4.machine.domain:port/full/path/to/file ,数字4,表示ipv4协议 curl -6 http://ipv6.machine.domain:port/full/path/to/file ,数字6,表示ipv6协议4.Curl与Wget的对比
Curl既能够下载,也能够上传;而Wget只能下载。
在需要递归下载的时候只能使用Wget,除此之外尽量使用curl。
参考:https://daniel.haxx.se/docs/curl-vs-wget.html
转载地址:http://yvlai.baihongyu.com/