深浅模式
curl默认发送get请求 例如:curl www.baidu.com
可以添加参数发送post请求 例如:curl -X -POST url
,可以将两个参数合并为-XPOST
, 可以简单理解默认的就是 curl -X -GET url
。
使用 -d
添加请求参数 使用 -H
设置标头 例如
shell
curl -XPOST localhost:8080/save -d '{
"name": "test_8cd49a0fa3be",
"age": 36
}' -H 'Content-Type:application/json'
-I
获取头信息
shell
curl -I localhost:8080
-o
下载文件到当前目录,参数后面可设置文件名称
shell
curl -0 文件名 url
--limit-rate
限制文件的下载速度,默认字节单位,不小心中断下载,可使用-C
恢复下载
使用 curl 测试网址时,大部分的会重定向,crul默认不会跟随,使用-L
跟随重定向
使用curl代理访问目标网址 curl –proxy “协议://用户名:密码@代理地址:端口” url
shell
curl --proxy "http://zs:123@127.0.0.0:7890" www.github.com