curl 的请求 和几个参数
-X [POST GET PUT DELETE]
参数执行http请求的方法
-d
参数用于发送post的请求的数据体
$curl -d'login=emma&password=123'-X POST https://google.com/login
或者
$curl -d 'login=emma' -d 'password=123' -X POST https://google.com/login
$ curl -d '@data.txt' https://google.com/login
-H
参数添加http请求头
$ curl -H 'Accept-Language: en-US' https://google.com
-b
参数用来发送服务器发送cookie
$ curl -b 'foo=bar' https://google.com
$ curl -b 'foo1=bar' -b 'foo2=baz' https://google.com
$ curl -b cookies.txt https://www.google.com
-A
参数 指定客户端的用户代理标头 即User-Agent
-c
参数将服务器设置的 Cookie 写入一个文件
$ curl -c cookies.txt https://www.google.com
-e
参数用来设置 HTTP 的标头Referer,表示请求的来源
curl -e 'https://google.com?q=example' https://www.example.com
-F
参数用来向服务器上传二进制文件
$ curl -F 'file=@photo.png' https://google.com/profile
-F参数可以指定 MIME 类型
$ curl -F 'file=.png;type=image/png' https://google.com/profile
上面命令会给 HTTP 请求加上标头Content-Type: multipart/form-data,然后将文件photo.png作为file字段上传
参数也可以指定文件名
$ curl -F 'file=@photo.png;filename=me.png' https://google.com/profile
-I
参数向服务器发出 HEAD 请求,然会将服务器返回的 HTTP 标头打印出来
$ curl -I https://www.example.com
-k
参数指定跳过 SSL 检测
$ curl -k https://www.example.com
-L
参数会让 HTTP 请求跟随服务器的重定向
$ curl -L -d 'tweet=hi' https://api.twitter.com/tweet
-o, --output
参数将服务器的回应保存成文件,等同于wget命令
$ curl -o example.html https://www.example.com
-O
参数将服务器回应保存成文件,并将 URL 的最后部分当作文件名
$ curl -O https://www.example.com/foo/bar.html
-u
参数用来设置服务器认证的用户名和密码
$ curl -u 'bob:12345' https://google.com/login
-x
参数指定 HTTP 请求的代理
$ curl -x socks5://james:cats@myproxy.com:8080 https://www.example.com
如果没有指定代理协议,默认为 HTTP
$ curl -x james:cats.com:8080 https://www.example.com
参考
https://blog.csdn.net/ygy162/article/details/106159044