# curl简单使用

  1. 最简单使用 curl https://www.baidu.com

  2. 省略进度条 curl https://www.baidu.com -s

  3. 下载 curl https://www.baidu.com -o baidu.txt

  4. 不会返回内容,只返回头 curl -I http://192.168.1.201/img/logo.png

  5. 添加请求头信息 -H curl -H "platform: iOS" https://www.baidu.com

  6. 添加ua referer curl --referer "http://baidu.com" --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.79" -I http://192.168.1.201/img/logo.png

[root@localhost conf]# curl -I https://baidu.com
HTTP/1.1 302 Moved Temporarily
Server: bfe/1.0.8.18
Date: Sat, 18 Feb 2023 14:25:30 GMT
Content-Type: text/html
Content-Length: 161
Connection: keep-alive
Location: http://www.baidu.com/
1
2
3
4
5
6
7
8

-o 下载响应内容 -d 指定请求内容 -H 指定请求头 -X 指定请求方法 -s 去掉进度条

curl -X GET -H "platform: iOS" -H "AppVersion: 7358" "http://ip:port/api/GetEstateRequest?CityEn=gz&CityCode=020&platform=iOS&EstateCode=0200013585&ImageHeight=700&ImageWidth=1000"

curl -X POST -H "Content-Type: application/json" -H "CityEn: sz" -d "{\"PageIndex\":1,\"PageCount\":9,\"IsLoadStaffRemark\":true}" "https://ip:port/api/SearchStaffRequest"

curl http://localhost:8080/staff?pageNum=1&pageSize=10 -s -H "Content-Type:application/json" -X POST -d "{\"age\":24}"
1
2
3
4
5