curl参数大全

`curl` 是一个非常强大的工具,支持许多参数来定制 HTTP 请求。以下是一些常用的 `curl` 参数及其简单实例:

1. -A, --user-agent <string>
   - 设置用户代理。


   - 实例:`curl -A "Wget/1.15" http://example.com`

2. -X, --request <command>
   - 指定请求的类型(如 GET, POST, PUT 等)。


   - 实例:`curl -X POST http://example.com/api/data`

3. -d, --data <data>
   - 向服务器发送数据。


   - 实例:`curl -d "param1=value1&param2=value2" http://example.com/api`

4. -F, --form <name=content>
   - 上传文件或模拟表单提交。


   - 实例:`curl -F "file=@localfile.txt" http://example.com/upload`

5. -G, --get
   - 使用 GET 请求发送 -d 参数。


   - 实例:`curl -G -d "key=value" http://example.com/api`

6. -H, --header <header>
   - 自定义请求头。


   - 实例:`curl -H "X-My-Header: 123" http://example.com`

7. -i, --include
   - 包括 HTTP 响应头在输出中。


   - 实例:`curl -i http://example.com`

8. -I, --head
   - 发送 HEAD 请求。

   

- 实例:`curl -I http://example.com`

9. -L, --location
   - 跟随重定向。


   - 实例:`curl -L http://example.com/redirect`

10. -o, --output <file>
    - 将输出保存到文件


    - 实例:`curl -o output.txt http://example.com/data`

11.-O, --remote-name
    - 保存远程文件的原始名称。


    - 实例:`curl -O http://example.com/file.zip`

12. -u, --user <user:password>
    - 提供用户认证信息。


    - 实例:`curl -u username:password http://example.com`

13. -x, --proxy <host:port>
    - 使用 HTTP 代理。


    - 实例:`curl -x http://proxyserver:port http://example.com`

14. -v, --verbose
    - 输出详细的调试信息。


    - 实例:`curl -v http://example.com`

15. --trace <file>
    - 将所有数据(包括头和体)写入文件。


    - 实例:`curl --trace output.txt http://example.com`

16. --trace-ascii
    - 类似于 --trace,但以文本形式输出。


    - 实例:`curl --trace-ascii http://example.com`

17. -k, --insecure
    - 允许连接到 SSL 站点而不需要证书验证。


    - 实例:`curl -k https://example.com`

18. --cacert <file>
    - 指定 CA 证书用于 SSL 验证。


    - 实例:`curl --cacert cacert.pem https://example.com`

19. --cert <cert>
    - 指定客户端证书文件。


    - 实例:`curl --cert clientcert.pem https://example.com`

20. --key <key>
    - 指定私钥文件。


    - 实例:`curl --key privatekey.key https://example.com`

  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值