设置user-agent

  1. curl -A "Chrome" http://www.baidiu.com

设置指定方法请求

  1. curl -X POST http://httpbin.org/post

只返回请求头的信息

  1. curl -I www.baidu.com

以post方法请求,并发送相应的参数

  1. curl -d arg1=1 -d arg2=2 -d arg3=3 http://httpbin.org/post
  2. curl -d "arg1=1&arg2=2&arg3=3" http://httpbin.org/post
  3. curl -d @filename http://httpbin.org/post

下载文件

  1. curl -O http://httpbin.org/image/jpeg

下载文件并重命名文件

  1. curl -o filename http://httpbin.org/image/jpeg

跟随重定向请求

  1. curl -L http://baidu.com

允许发生ssl不安全的请求

  1. curl -k https://www.12306.cn

设置头信息

  1. curl -o filename -H "accept:image/png" http://httpbin.org/image/jpeg

设置cookies

  1. curl -b arg1=1 http://httpbin.org/post

查询公网IP

  1. $ curl ifconfig.me
  2. 49.80.161.165