linux命令-curl

1.什么是curl

curl命令是一个利用URL规则在命令行下工作的文件传输工具。它支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称curl为下载工具。作为一款强力工具,curl支持包括HTTP、HTTPS、ftp等众多协议,还支持POST、cookies、认证、从指定偏移处下载部分文件、用户代理字符串、限速、文件大小、进度条等特征。做网页处理流程和数据检索自动化,curl可以祝一臂之力。 它还用于汽车,电视机,路由器,打印机,音频设备,手机,平板电脑,机顶盒,媒体博爱泛起,并且是每天影响数十亿人类数以千计的软件应用在互联网传输骨干。

2.curl的支持

DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, HTTP/2, cookies, user+password authentication (Basic, Plain, Digest, CRAM-MD5, NTLM, Negotiate and Kerberos), file transfer resume, proxy tunneling and more

3.最新版本与源代码地址

最新版本:The most recent stable version is 7.56.1, released on 23rd of October 2017
源代码托管地址:https://github.com/curl/curl

4.curl官网

https://curl.haxx.se/

5.curl下载地址

https://curl.haxx.se/download.html

6.centos下curl安装

目前centos下一般默认都安装了curl,如果没有安装推荐使用yum安装
yum install curl -y

7.PDF书籍和官方文档

https://curl.haxx.se/docs/
书里面详细的介绍了curl和libcurl等等。

8.curl的具体使用官方文档

https://curl.haxx.se/docs/manpage.html

9.curl常用的一些选项

9.1 下载这个b.tok.fit网页,然后到本地,文件名为test.html
curl http://b.tok.fit -o test.html
curl默认是把内容输出到标准输出,也就是控制台

9.2 下载b.tok.fit 这个网页,然后到本地,文件名为test.html。下载过程中不显示进度信息。

curl http://b.tok.fit –silent -o test.html
curl http:// b.tok.fit -s -o test.html
此模式也成为静默模式

9.3 下载的时候显示进度条

curl http:// b.tok.fit -o test.html –progress

9.4 下载的时候设置referer

curl http://b.tok.fit -o test.html –referer http://www.xiu8.com

9.5 使用curl设置cookies

curl http://b.tok.fit -o test.html –cookie-jar cookie_file

9.6 设置用户客户端版本

curl http://b.tok.fit -o test.html –user-agent “Mozilla/5.0”
curl http://b.tok.fit -o test.html -A “Mozilla/5.0”

9.7传输多个头部信息

curl -H “Host:test” -H “accept-languager:zh-cn” http://b.tok.fit -o test.html

9.8传输post信息

curl -X POST -d {“date”:”2017011000″} -H “App-Key:8luwapkv8rfvl” -H “Nonce=1251800058” -H “Timestamp=1515574914” -H “Signature=feae41a-ad19e7ab3618977afc2ba50853987cdf” http://b.tok.fit /message/history.json

9.9 下载中限速

curl http://b.tok.fit -o test.html –limit-rate 50k

9.10curl使用用户和密码登录

curl -u user:passwd http://b.tok.fit -o test.html

9.11 打印服务器返回的http头部信息(头信息在打印的开头)

curl -i http://b.tok.fit -o test.html

9.12 设置代理

curl -x 10.0.16.47:80 -I ‘http://b.tok.fit’

10.参考博文

http://man.linuxde.net/curl

Previous Post

linux命令-date

Next Post

linux命令-wget

Related Posts