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

curl 的请求 和几个参数

root5年前 (2021-06-18)linux1570

-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

分享给朋友:

相关文章

CentOS修改hostname

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

linux 更换apt的源

sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list将archive.ubunt...

Ubuntu apt-get彻底卸载软件包

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

修改linux时区

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

apach 启动失败 可能因为安全策略

apach 启动失败 可能因为安全策略

执行 setenforce 0再次启动systemctl restart httpdOK 搞定...

Python2 的Popen在docker中执行会挂起主进程

python2.7因业务需求。要把程序放入到docker容器中但是在docker执行的时候程序出现异常缓慢的情况检查函数执行情况发现当第一个线程执行到popen的时候会导致所有线程的挂起p1 = subprocess.P...