cURL工具的使用技巧

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

内容简介: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工具的使用技巧》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

编译器设计

编译器设计

Keith Cooper、Linda Torczon / 郭旭 / 人民邮电出版社 / 2012-12 / 99.00元

深入剖析现代编译器运用的算法和技术 强调代码优化和代码生成 体现编译原理教学的最新理念 本书旨在介绍编译器构造法中的艺术和科学。书中深入分析现代编译器后端所用的算法和技术,重点讨论代码优化和代码生成,详细介绍了用几个编程语言编写的示例等。 Keith D. Cooper 莱斯大学计算机科学系计算工程专业Doerr特聘教授,曾任该系系主任。Cooper博士的研究课题涵盖过程间......一起来看看 《编译器设计》 这本书的介绍吧!

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

在线压缩/解压 HTML 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换