Linux 命令 - curl: transfer a URL
2015-04-16 14:13
204 查看
命令格式
curl [options] [URL...]命令参数
-0, --http1.0强制使用 HTTP/1.0 发送请求
-A, --user-agent
指定用户代理
-b/--cookie <name=string/file>
传递 cookie
-c, --cookie-jar <file name>
完成操作后,将 cookie 写入到指定的文件
-C, --continue-at <offset>
断点续传
-d, --data <data>
以 POST 方式向 HTTP 服务器发送指定的数据
--data-ascii <data>
-d/--data 选项的别名
--data-binary <data>
以 POST 方式向 HTTP 服务器发送指定的二进制数据
-D/--dump-header <file>
将响应的头部信息输出到指定的文件
-e, --referer <URL>
指定 HTTP 请求的 Referer 头部信息
-G, --get
与 -d 选项一起使用时,以 GET 方式向 HTTP 服务器发送指定的数据
-h, --help
显示帮助信息
-H, --header <header>
传递额外的头信息
-i, --include
输出信息时包含协议的头部信息
-I, --head
只显示文档信息
-k, --insecure
允许不使用 CA 证书执行 SSL 连接
--limit-rate <speed>
限定最大的传输速率
-L, --location
重定向
-o, --output <file>
将响应消息写到文件而不是标准输出
-O, --remote-name
将响应消息写到文件,文件名与远程文件一致
--trace <file>
将调试信息输出到指定的文件
--trace-ascii <file>
与trace相同,但是不显示十六进制信息
-x, --proxy <proxyhost[:port]>
指定 HTTP 代理
-X, --request <command>
指定请求方法,而不是默认的 GET 方法(FTP 协议默认的请求方法是 LIST)
-u, --user <user:password>
指定用户名和密码
-U, --proxy-user <user:password>
指定代理的用户名和密码
-v, --verbose
显示更为详细的通信信息,如果觉得信息不够详细,可以考虑使用 --trace 或 --trace-ascii 选项
-V, --version
显示版本信息
实例
a) 查看网页源码curl http://www.example.com/[/code]
b) 保存网页源码curl -o example.html http://www.example.com/[/code]
c) 显示 HTTP 响应的头部信息curl -i http://www.iana.org/domains/example[/code]
d) 发送 HTTP POST 请求curl -d "username=huey2672&password=123456" http://hello.com/accounts/login/[/code]
e) 发送 HTTP GET 请求curl -G -d "client_id=gFN5VBsozdvu8hBZzHsbrmlK&q=hello&from=en&to=zh" http://openapi.baidu.com/public/2.0/translate/dict/simple[/code]
f) 添加额外的头部信息curl -H "Content-Type: application/json" http://www.example.com/[/code]
g) 指定源地址curl -e http://www.baidu.com/ http://www.example.com/
h) 指定 HTTP 客户端信息curl -A "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)" http://www.example.com/[/code]
i) 使用 cookiecurl -b "username=root; password=123456" http://www.example.com/ curl -b cookie.txt http://www.example.com/[/code]
j) 输出重定向后的响应信息curl -L http://www.iana.org/domains/example[/code]
k) 若需要 HTTP 认证,指定用户名和密码curl -u name:password http://www.example.com/[/code]
相关文章推荐
- curl命令_Linux curl 命令用法详解:利用URL规则在命令行下工作的文件传输工具
- linux 命令访问url: curl http://www.baidu.com/index.html
- linux命令学习笔记(62)-curl命令-url下载工具
- linux定时任务crontab的使用,curl命令中url避免使用&,或对&进行转义
- 【转】命令行浏览器 curl 命令详解,Linux中访问url地址
- 关于curl - 命令行浏览器 curl 命令详解,Linux中访问url地址
- 使用curl命令查看访问url的时间
- Linux curl命令参数详解
- linux curl 命令详解,以及实例
- Linux命令curl
- Linux curl命令参数详解--转载
- linux curl命令用法总结
- linux下curl命令详解
- 在linux下使用curl访问 多参数url GET参数问题
- linux curl 命令详解,以及实例
- Linux curl命令使用
- Linux中Curl命令couldn't connect to host解决方案 php操作Curl(http,https)无法获取远程数据解决方案
- linux命令curl做POST请求
- Linuxcurl命令参数详解
- Linux命令CURL用法