curl常用的命令

2018-01-28  本文已影响0人  我有一只碗

发送单个请求,将结果输出到控制台

# 发送单个请求,将结果输出到控制台
curl http://www.centos.org

将文件下载到本地

# 将文件下载到本地并命名为docker,html
curl -o docker.html http://python.usyiyi.cn/translate/docker/index.html
# 将文件保存到本地并采用默认命名
curl -O http://python.usyiyi.cn/translate/docker/index.html

查询单词的含义

# 查询bash单词的含义
curl dict://dict.org/d:bash

发送POST请求

# 发送POST请求
curl -d "price=20" http://127.0.0.1:8080

自定义Header的请求

# 自定义Header的请求
curl -H 'Host: 157.166.226.25' -H 'Accept-Language: es' -H 'Cookie: ID=1234' http://cnn.com

除了使用GET和POST协议外,还可以通过 -X 选项指定其它协议

curl -I -X DELETE http://127.0.0.1:8080/usr/1

使用一个文件发送POST请求

curl -d "@data.json" -H "Content-Type: application/json" -X POST http://localhost:8080
上一篇 下一篇

猜你喜欢

热点阅读