curl的一些常见问题



-d参数用于发送 POST 请求的数据体。
$ curl -d'login=emma&password=123'-X POST https://google.com/login
# 或者
$ curl -d 'login=emma' -d 'password=123' -X POST  htt

-e参数用来设置 HTTP 的标头Referer,表示请求的来源。
curl -e 'https://google.com?q=example' https://www.example.com

-F参数用来向服务器上传二进制文件。
$ curl -F 'file=@photo.png' https://google.com/profile




-k参数指定跳过 SSL 检测。
$ curl -k https://www.example.com


--limit-rate用来限制 HTTP 请求和回应的带宽,模拟慢网速的环境。
$ curl --limit-rate 200k https://google.com

上面命令将带宽限制在每秒 200K 字节。

-o参数将服务器的回应保存成文件,等同于wget命令。
$ curl -o example.html https://www.example.com

上面命令将www.example.com保存成example.html。


-O参数将服务器回应保存成文件,并将 URL 的最后部分当作文件名。
$ curl -O https://www.example.com/foo/bar.html

上面命令将服务器回应保存成文件,文件名为bar.html。


-x参数指定 HTTP 请求的代理。
$ curl -x socks5://james:cats@myproxy.com:8080 https://www.example.com

上面命令指定 HTTP 请求通过myproxy.com:8080的 socks5 代理发出。

如果没有指定代理协议,默认为 HTTP。


-X参数指定 HTTP 请求的方法。
$ curl -X POST https://www.example.com

上面命令对https://www.example.com发出 POST 请求。


阅读量: 368
发布于:
修改于: