1.发送 HTTP 请求:使用 curl 发送 HTTP 请求,例如:
curl http://example.com/
2.保存下载的文件:使用 -O
或 -o
参数可以将下载的文件保存到本地,例如
curl -O http://example.com/file.zip
curl -o localfile.txt http://example.com/remote.txt
3.设置 HTTP 请求头:使用 -H
参数可以设置 HTTP 请求头,例如:
curl -H "Content-Type: application/json" -H "Authorization: Bearer token" http://example.com/api
4.发送 POST 请求:使用 -X POST
参数可以发送 POST 请求,例如:
curl -X POST -d "name=John&age=30" http://example.com/api/create
5.发送文件数据:使用 -F
参数可以上传文件或表单数据,例如:
curl -F "file=@/path/to/file" http://example.com/upload
curl -F "name=John" -F "age=30" http://example.com/api/create
6.设置代理服务器:使用 -x
参数可以设置代理服务器,例如:
curl -x http://proxy.example.com:8080 http://example.com/
7. 摸拟浏览器访问:使用 -A
参数可以设置 User-Agent,模拟浏览器访问,例如