Posted on July 5, 2013
  1. 只展示正文

  2. -o/–output [file]

    Write output to file instead of stdout 保存到本地

     curl -o [filename]
  3. -L/–location

    Follow Location 自动跳转

     curl -L
  4. -i/–include

    Include protocol headers in the output 展示包括响应头

     curl -i
  5. -I/–head

    Show document info only 只展示headers

     curl -I
  6. -v/–verbose

    Make the operation more talkative 可以显示一次http通信的整个过程,包括端口连接和http request头信息

     curl -v
  7. -d/–data [data]

    HTTP POST data 使用post发送数据

     curl -d content=123 -d contact=abc
     curl -d content=123 -data 'a=1&b=2'


     curl --data-urlencode 'content=123 sds' -d contact=abc 
  8. -X/–request [command]

    Specify request command to use 指定http动词,默认是GET

     curl -X PUT   
     curl -X POST   
  9. -F/–form [name=content]

    Specify HTTP multipart POST data 使用enctype=’multipart/form-data’表单提交数据

     curl -F [email protected]/tmp/image.jpg -F content=hello
  10. -e/–referer

    Referer URL 指定referer

    curl --referer
  11. -A/–user-agent [string]

    User-Agent to send to server

  12. -b/–cookie [name=string/file]

    Cookie string or file to read cookies from 附加cookie

    TODO 设置多个

  13. -H/–header [line]

    Custom header to pass to server 添加header

    curl -H 'Host:'
  14. -u/–user [user[:password]]

    Set server user and password 设置http认证

    curl --user name:password
  15. get 发送json body

curl -v -H 'Content-Type: application/json' -X GET -d '{"Uin":"123"}' ''