当前位置:首页 > linux > 正文内容

curl 的请求 和几个参数

root4年前 (2021-06-18)linux973

-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=@photo.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@myproxy.com:8080 https://www.example.com




参考

https://blog.csdn.net/ygy162/article/details/106159044

 

扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://zhiqiu.top/?id=128

分享给朋友:

相关文章

mvware的NAT网络模式设置和端口映射

mvware的NAT网络模式设置和端口映射

在日常众多的虚拟机使用中,VMware的使用还是简单粗暴的。但是个人觉得有点重了,这都是题外话。当我们建立好我们的虚拟主机时,可能会遇见没有网络。网络模式常见的:桥接模式和NAT模式桥接模式很好理解就是跟宿主主机一样的网络情况。NAT模式比...

supervisor的安装使用

一、supervisor简介Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启。它是通过fork/exec的方式把这些被管理的进程当作supe...

修改linux时区

ubuntu:rm  /etc/localtimeln -sf /usr/share/zoneinfo/Asia/Shanghai  /etc/localtimecentos echo "A...

docker 日志查看

通过如下命令来获取容器的日志地址 docker inspect --format '{{.LogPath}}' 97069f94437bcat命令查看上述命令找到的日志地址cat /...

linux创建用户和用户组

添加用户和组groupadd testuseradd -r -g test test删除用户和组userdel testgroupdel test给文件添加用户组和用户归属chown -R test:test test_file...

永久更改Linux系统主机名hostname

1)sudo vim /etc/hostname如果你不更新/etc/hosts文件,那么有的程序,如sudo,不知道如何解析新的主机名。所以如果更改个人电脑的主机名,那么新的主机名应该解析为127.0.0.1。2)sudo hostnam...