什么是Curl?
cURL是在命令行下工作的文件传输工具。
他的语法是基于URl的语法。
它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称cURL为下载工具。
cURL还包含了用于程序开发的libcurl。
Curl支持协议
cURL支持的通信协议有:
FTP、FTPS、HTTP、HTTPS、TFTP、SFTP、Gopher、SCP、Telnet、DICT、FILE、LDAP、LDAPS、IMAP、POP3、SMTP和RTSP。
curl还支持SSL认证、HTTP POST、HTTP PUT、FTP上传,
HTTP form based upload、proxies、HTTP/2、cookies、用户名+密码认证(Basic, Plain, Digest, CRAM-MD5, NTLM,
Negotiate and Kerberos)、file transfer resume、proxy tunneling。
Curl场景使用
HTTP方法
在每一个HTTP请求中,都有一个对应的方法,常用的方法有:GET、POST、HEAD和PUT。
如果在一个curl命令中不指定具体的方法,那么默认的就是使用GET方法。对于其它的方法,可以在curl命令中指定:
methodoption
POST
-d或-F
HEAD
-I
PUT
-T
Header
在curl中,使用 -i 选项可以显示Response的Header信息,连同Body数据:
$ curl -i
结果:
HTTP/1.1 200 OK
Accept-Ranges: //代码效果参考:http://hnjlyzjd.com/xl/wz_24199.html
bytesCache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: Keep-Alive
Content-Length: 2381
Content-Type: text/html
Date: Mon, 17 Sep 2018 10:26:42 GMT
Etag: "588604dd-94d"
Last-Modified: Mon, 23 Jan 2017 13:27:57 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
/span]
[span class="hljs-name">html] [span class="hljs-name">head][span class="hljs-name">meta http-equiv=content-type content=text/html;charset=utf-8][span class="hljs-name">meta
http-equiv=X-UA-Compatible content=IE=Edge][span class="hljs-name">meta content=always //代码效果参考:http://hnjlyzjd.com/xl/wz_24197.html
name=referrer][span class="hljs-name">link rel=stylesheet type=text/css href=][span class="hljs-name">title]百度一下,你就
知道]] [span class="hljs-name">body link=#0000cc] ...