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

curl 的请求 和几个参数

root3年前 (2021-06-18)linux621

-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

分享给朋友:

相关文章

linux 安全策略关闭

#防火墙关闭systemctl stop firewalld.service#永久关闭防火墙systemctl disable firewalld.service#临时关闭selinuxsetenforce 0#永久关闭sed -i &qu...

linux添加用户,修改用户密码,设置文件/文件夹的归属用户和用户组 、 hostname

添加用户useradd  username  修改用户密码passwd username修改文件用户和用户组chown -R username:group  /project/修改归属用户chown&...

一行 Python 实现并行化 -- 日常多线程操作的新思路

一行 Python 实现并行化 -- 日常多线程操作的新思路

Python 在程序并行化方面多少有些声名狼藉。撇开技术上的问题,例如线程的实现和 GIL1,我觉得错误的教学指导才是主要问题。常见的经典 Python 多线程、多进程教程多显得偏“重”。而且往往隔靴搔痒,没有深入探讨日常工作中最有用的内容...

服务查看启动

服务启动、停止和重启service   xxx  start  service   xxx  stopservice   xxx ...

zabbix 中文乱码

zabbix 中文乱码

原因是因为zabbix没有支持中文的字体,在win找到一个中文字体文件名是:simkai.ttf把这个文件复制到服务器的/usr/share/zabbix/fonts  路径下然后修改zabbix的配置文件vim /us...

go启动时遇见的问题和操作

go env -w GOARCH=amd64设置环境为amd64go env  ==  go environment查询环境变量go get -u github.com/gin-gonic/gin安装gin框架...