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

面向在纯命令行环境调接口、下载文件、排查 HTTP 问题的工程师。curl 与 wget 虽常被并列,定位不同:curl 是 HTTP 客户端,适合调接口、带方法/Header/Cookie;wget 偏文件抓取,断点续传和递归镜像更顺手。读完能为每种任务选对工具,用 wget -c 续传大文件,用 curl -v/-w 定位接口问题,并处理代理与认证。

Web 服务·共 34 条命令·最后更新 2026-08-02
curlwget下载http命令行

基础请求 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",否则服务端按表单解析。

官方参考来源

下方为命令对应的官方权威文档,供你核对最新用法与深入查阅。

由 巧匠 维护

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

联系我们

命令或描述有误?提交反馈、商务合作或产品建议都可发送邮件给我们。

联系我们