curl基本使用

发布: 2019-12-16 23:30:02标签: linux

curl基本使用

  • curl: 发送get请求

    01curl https://www.example.com
    复制代码
  • -A/H: 指定 User-Agent

    01curl -A 'Mozilla/5.0 ' https://test.com
    复制代码
  • -b: 发送cookie

    01curl -b 'foo=bar' https://test.com
    复制代码
  • -c: 保存服务器设置cookie到文件

    01curl -c cookie.txt https://test.com
    复制代码
  • -d: 发送post请求的数据体(后可以跟文件)

    01# header会自动Content-Type : application/x-www-form-urlencoded
    02cul -d 'username=aa&password=bb' -X post https://test.com
    复制代码
  • -e: 设置头部Referer, 请求来源

    01curl -e 'https://test.com' https://test.com
    复制代码
  • -F: 发送二进制文件

    01curl -F 'file=**.psd' https://test.com
    复制代码
  • -G: URL上的params

    01curl -G -d 'a=1' -d 'b=2' https://test.com
    复制代码
  • -i: 打印服务端回应HTTP头

    01curl -i https://test.com
    复制代码
  • -I: 向服务器发出 HEAD 请求,然会将服务器返回的 HTTP 标头打印出来

    01curl -I https://test.com
    复制代码
  • -k: 跳过SSL检测

    01curl -k https://test.com
    复制代码
  • -L: 跟随重定向

    01curl -L https://test.com
    复制代码
  • ---limit-rate: 限制带宽

    01curl --limit-rate 10k https://test.com
    复制代码
  • -o: 保存服务器回应的文件

    01curl -o test.txt https://test.com
    复制代码
  • -O: 保存服务器文件,使用最后斜线后作为名字

    01curl -O https://test.com
    复制代码
  • -s: 不输出错误信息

  • -u: 用户密码认证

    01curl -u 'username:aaa' https://test.com
    复制代码
  • -v: 输出通信的过程

    01curl -v https://test.com
    复制代码
  • -x: 指定http代理

    01curl -x proxy.com https://test.com
    复制代码
  • -X: 指定请求方法

    01curl -X post https://test.com
    复制代码