Curl 命令在线生成器

轻松生成 curl 命令

生成 Curl 命令

什么是 Curl?

Curl (Client URL) 是一个用于传输数据的命令行工具和库。它广泛用于脚本、终端和 API 测试。

Curl 支持多种协议,包括 HTTP、HTTPS、FTP、FTPS、SFTP 等,使其在各种网络任务中非常versatile。

主要特点:

  • HTTP 请求方法(GET、POST、PUT、DELETE 等)
  • 自定义头部和 cookie
  • 表单提交和文件上传
  • 认证(Basic、Bearer、Digest)
  • 代理支持
  • 证书验证
  • 详细调试和输出

常见用途:

  • API 测试和探索
  • 下载文件
  • 检查网站响应和头部
  • 调试网络问题
  • 通过 shell 脚本自动化
  • 性能测试

Curl 在大多数操作系统上都可用,是 Linux、macOS 和现代 Windows 安装中的标准工具。

Curl 参数说明

Curl 提供了许多参数来自定义 HTTP 请求。以下是最常用的参数:

-X, --request

Specifies the HTTP request method to use (GET, POST, PUT, DELETE, etc.)

-H, --header

Adds a custom header to the request (e.g., -H 'Content-Type: application/json')

-d, --data

Sends data in the request body, typically used with POST, PUT (e.g., -d '{"key":"value"}')

-b, --cookie

Sends cookies with the request (e.g., -b 'name=value; name2=value2')

-c, --cookie-jar

Saves cookies to a file after the request completes

-u, --user

Provides username:password for server authentication (e.g., -u 'username:password')

-i, --include

Includes the HTTP response headers in the output

-v, --verbose

Makes curl display detailed information about the request and response process

-k, --insecure

Allows curl to proceed even when SSL connections are considered insecure

-L, --location

Follows redirects if the server responds with a 3XX status code

-o, --output

Saves the response body to a file instead of displaying it (e.g., -o filename.txt)

-O, --remote-name

Saves the file with the same name as it appears on the remote server

--compressed

Requests a compressed response and automatically decompresses it

-A, --user-agent

Specifies the User-Agent string to send (e.g., -A 'Mozilla/5.0...')

--max-time

Sets maximum time allowed for the transfer (in seconds)

这些参数可以组合使用,以创建高度自定义的请求。有关选项的完整列表,您可以随时参考 curl --help 或官方 curl 文档。