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

curl 的请求 和几个参数

root5年前 (2021-06-18)linux1535

-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

分享给朋友:

相关文章

ssh自动添加hostkey到know_hosts

有时后端daemon或者脚本在执行ssh连接时,会遇到以下提示:The authenticity of host 'git.sws.com (10.42.1.88)' can't be establishe...

CentOS修改hostname

vi /etc/hostname写下你的hostname重启reboot启动后,查看主机名sudo hostname...

Ubuntu apt-get彻底卸载软件包

apt-get的卸载相关的命令有remove/purge/autoremove/clean/autoclean等。具体来说:apt-get purge / apt-get –purge remove 删除已安装包(不保留配置文件)...

压缩&解压命令

tar 命令-c 建立压缩文档-x 解压-t 查看内容-r 向压缩归档文件末尾追加文件-u:更新原压缩包中的文件上面的参数只能使用一个,跟下面的参数连用-z:有gzip属性的-j:有bz2属性的-Z:有compress属性的-v:...

死亡进程导致在办公室莫名背锅后平反昭雪艰辛之路

死亡进程导致在办公室莫名背锅后平反昭雪艰辛之路

背景:之前就有一个在我账户名下的问题程序,但是并不是我启动的,绝对不是我启动的。但是找不到原因就莫名的背起了锅。然后默默修改了密码(其实然并卵,下面详聊原理),该机器管理员把我踢出了root组(因为没啥程序在上面)起因:今日突然发现一个进程...

centos的新主机配置网络

centos的新主机配置网络

背景:公司因项目开发需要购置了两台主机。因为配置网络的大哥又是不在公司,但是又着急使用新主机。(旧的已经卡成狗腿了)急需解决问题,首先电脑刚插入网线又问题,不亮。只有一个网卡亮但是并不是Internet的网卡。其他四个网卡插入均不亮。换个网...