博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux下的cURL工具概述
阅读量:4180 次
发布时间:2019-05-26

本文共 2306 字,大约阅读时间需要 7 分钟。

cURL包含一个命令行工具curl和一个类库libcurl,能够以非交互的模式通过URL传输数据。

1.

官网https://curl.haxx.se/

源代码https://github.com/curl/curl

最新版本:2016年9月发布的7.50.2

2.cURL支持多种主流的传输协议

  • HTTP
  • HTTPS
  • FTP
  • SFTP
  • SCP

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/

你可能感兴趣的文章
Mycat+SpringBoot完成分库分表
查看>>
基于JMH检验多种生成随机数方法的效率
查看>>
读写文件效率测试
查看>>
优雅停止 SpringBoot 服务
查看>>
轻松读懂WSDL文件
查看>>
FastJson中JSONPath的应用
查看>>
文件下载
查看>>
手动安装chrome插件
查看>>
mysql怎么把'1,2,3'转成1,2,3
查看>>
POI生成excel并设置过滤范围
查看>>
RSAUtils工具类
查看>>
常用的集合之间的转换
查看>>
list复制 浅拷贝和深拷贝
查看>>
查找出一个字符串不重复字符的最大长度
查看>>
2的次幂
查看>>
3的次幂
查看>>
求一个数的平方根
查看>>
mysql查看死锁和解锁
查看>>
对synchronized的使用一点浅解
查看>>
Intellij IDEA 自定义 LIVE TEMPLATES
查看>>