cURL工具的使用技巧

栏目: 服务器 · 发布时间: 6年前

内容简介:cURL是一个利用URL语法在命令行下工作的文件传输工具,1997年首次发行。它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称cURL为下载工具。cURL还包含了用于程序开发的libcurl。 – BaiduDICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTPRef

cURL是一个利用URL语法在命令行下工作的文件传输工具,1997年首次发行。它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称cURL为下载工具。cURL还包含了用于程序开发的libcurl。 – Baidu

0x01 cURL支持的协议

DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP

Ref:https://ec.haxx.se/protocols-curl.html

0x02 常用选项

curl -v http://example.com
curl -L http://example.com
curl -d "username=Rvn0xsy" http://example.com
curl -o ~/Download/down.zip http://example.com/download.zip
curl -s -o ~/Download/down.zip http://example.com/download.zip
curl -O ~/Download/down.zip http://example.com/download.zip
curl http://example.com/ --limit-rate 200K
curl --max-filesize 100000 http://example.com/
curl --range 100-1099 http://example.com/download.zip
curl --data-urlencode "name=John Doe (Junior)" http://example.com
curl --data-urlencode user@contents.txt http://example.com #user的内容再contents.txt中
curl -G http://example.com
curl -H "Transfer-Encoding: chunked" http://example.com
curl --user-agent/-A/-H 'User-Agent: http://example.com'

0x03 认证

cURL支持四种认证:

-u <username:password>

0x04 任意HTTP方法

cURL -X <POST/GET/OPTIONS/PUT> http://example.com

0x04 上传文件

支持:FILE, FTP, FTPS, HTTP, HTTPS, IMAP, IMAPS, SCP, SFTP, SMB, SMBS, SMTP, SMTPS and TFTP.

HTTP: curl -T upload.zip http://example.com/ # PUT

FTP: curl -T upload.zip ftp://example.com/

SMTP: curl -T mail smtp://mail.example.com/ --mail-from user@example.com

0x05 网卡

curl --interface eth1 https://www.example.com/

curl --interface 192.168.0.2 https://www.example.com/

curl --interface machine2 https://www.example.com/

0x06 指定源端口

curl --local-port 4000-4200 https://example.com/

0x07 代理

支持代理:

  • http
  • socks
curl -x 192.168.0.1:8080 http:/example.com/
curl -x socks4://proxy.example.com http://www.example.com/
curl --socks4 proxy.example.com http://www.example.com/
curl --socks4a proxy.example.com http://www.example.com/
curl -x socks4a://proxy.example.com http://www.example.com/
curl -x socks5://proxy.example.com http://www.example.com/
curl --socks5 proxy.example.com http://www.example.com/
curl -x socks5h://proxy.example.com http://www.example.com/
curl --socks5-hostname proxy.example.com http://www.example.com/

代理认证

curl -U daniel:secr3t -x myproxy:80 http://example.com

0x08 HTML表单上传文件

<form action="submit.cgi" method="post" enctype="multipart/form-data">
   Name: <input type="text" name="person"><br>
   File: <input type="file" name="secret"><br>
   <input type="submit" value="Submit">
</form>

curl -F person=anonymous -F secret=@file.txt http://example.com/submit.cgi

0x09 COOKIE

读取cookie

curl -L -b cookies.txt http://example.com

将cookie写入文件

curl -c cookie-jar.txt http://example.com

REF

  • https://legacy.gitbook.com/book/bagder/everything-curl

以上所述就是小编给大家介绍的《cURL工具的使用技巧》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

2小时品牌素养

2小时品牌素养

邓德隆 / 2009-1 / 38.00元

《2小时品牌素养(第2版)》第一次系统发布有关中国企业的品牌竞争力分析报告,揭示了中国一流企业在品牌战略上面临的深重危机,提出了定位突围之道和实践方法。全书分上下两篇,上篇详细分析了定位的原理,给出定位的三种方法,并特别为中国企业走向世界指出了三条出路;下篇以王老吉品牌战略历程为例,细致论述了一个品牌打造的完整过程,并就品牌实践中的许多关键问题进行了阐述和研讨。作为兼顾理论和实践的第2版,《2小时......一起来看看 《2小时品牌素养》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具