curl / wget 速查表 - 命令行文件下载与 HTTP 请求大全

下载文件、调接口、排查 HTTP 问题,curl 和 wget 是命令行首选。这里按请求、下载、认证、调试分组,并给出两者对照,配示例直接复制。

Web 服务·共 34 条命令·最后更新 2026-08-02
返回 Web 服务

基础请求 Requests 6

curl https://api.test
curl 输出响应体到 stdout
curl -O https://x/file.zip
curl 按原文件名保存(-O 大写)
curl -o out.html https://x
curl 保存到指定文件名
wget https://x/file.zip
wget 默认按原文件名下载
wget -O out.html https://x
wget 保存到指定文件名
curl -I https://x
curl 只取响应头(HEAD)

请求方法 Method 5

curl -X POST https://x
curl 指定请求方法
curl -d 'a=1&b=2' https://x
curl POST 表单数据(默认 application/x-www-form-urlencoded)
curl -d @body.json https://x
curl 从文件读取请求体
curl -H 'Content-Type: application/json' -d '{"a":1}' https://x
curl POST JSON
curl -T file.zip https://x/upload
curl 上传文件(PUT)

下载与续传 Download 5

curl -C - -O https://x/big.iso
curl 断点续传
wget -c https://x/big.iso
wget 断点续传(-c)
wget -r -np -l 2 https://x/dir/
wget 递归下载(限制层级)
curl -L https://x
curl 跟随重定向(-L)
wget --mirror -p --convert-links https://x
wget 镜像整站并本地化链接

认证与代理 Auth & Proxy 4

curl -u user:pass https://x
curl 基础认证
curl -x http://proxy:8080 https://x
curl 走 HTTP 代理
wget -e use_proxy=yes -e http_proxy=http://proxy:8080 https://x
wget 走代理
curl -k https://x
curl 跳过 TLS 证书校验(不安全)

调试与排错 Debug 5

curl -v https://x
curl 详细过程(含请求/响应头)
curl -s -o /dev/null -w "%{http_code}" https://x
curl 只取 HTTP 状态码
curl -w "@curl-format.txt" https://x
curl 用格式文件输出计时/指标
wget -S https://x
wget 打印响应头
wget --debug https://x
wget 调试模式

curl vs wget 对照 4

上传文件
curl 强(支持 PUT/POST 任意体);wget 较弱
递归镜像整站
wget 强(--mirror);curl 需手动脚本
默认输出
curl 打到 stdout;wget 直接落盘
易用性
wget 下载开箱即用;curl 调试/接口更灵活

💡 提示

  • 下载大文件优先用续传:curl -C - -O 或 wget -c,网络断了不重来。
  • curl 默认不跟随重定向,要加 -L;wget 默认跟随。
  • 只取状态码排查服务:curl -s -o /dev/null -w "%{http_code}"。
  • POST JSON 时必须带 -H "Content-Type: application/json",否则服务端按表单解析。

官方参考来源

命令整理自以下官方文档,点击核对最新用法。

由 LaoHand 维护

公开更新于 2026年8月2日,内容持续校对官方文档。

发现错误?反馈给我们

命令或描述有误?提交 issue 帮助我们修正。

发现错误?反馈给我们