Instrument: curl

 

  1. 将query string编码后发送
    curl 'ram.canto.com/rt/tt' --data-urlencode 'name=啊&age=55' --get

    --data-urlencode <data> HTTP POST data url encoded

    --get           Put the post data in the URL and use GET

  2. --data <data>   HTTP POST data
    # curl会以application/x-www-url-encoded 方式发送 POST 请求
    # --data-binary:则保留文件中的回车符和换行符,不做任何转换

     

    curl ram.canto.com/rt/tt --data 'name=啊&age=55'

     

     

     

     

      

  3. curl ram.canto.com/rt/tt --data @post.txt

      

  4. 上传文件 'content-type': 'multipart/form-data; boundary=------------------------fa4ec5c096848e3a'
    curl ram.canto.com/rt/tt --form memento=post.txt

      

    curl ram.canto.com/rt/tt --form memento=@post.txt

      

    curl ram.canto.com/rt/tt --form 'memento1=@post.txt;type=application/json' --form 'memento2=@post.txt;type=application/pdf'

     

  5. 只显示http_code

    curl -o /dev/null -s -w %{http_code} https://www.cnblogs.com

     

  6. 显示下载进度条

    curl -# -O http://www.test.com/dodo1.JPG

     

  7. --range <range>  Retrieve only the bytes within RANGE 获取某段范围内数据 0-N 字节数

     

     

     

  8. 通过ftp下载文件 

    curl -O -u 用户名:密码 ftp://www.test.com/dodo1.JPG
    curl -O ftp://用户名:密码@www.test.com/dodo1.JPG

     

  9. --proxy [protocol://]host[:port]  Use this proxy 
    curl --proxy socks5://192.168.100.100:1080 https://www.cnblogs.com

     

  10. 获取cookie
    curl -c cookie.txt https://www.baidu.com -o /dev/null -s

     

  11. 获取返回的所有headers
    curl https://www.baidu.com -o /dev/null -s --dump-header header.txt

     

  12. 请求携带cookie     --cookie <data|filename>  Send cookies from string/file  curl不会校验cookie
    curl https://www.baidu.com -o /dev/null -s --cookie header.txt

     

  13. When listing an FTP directory, this switch forces a name-only view --list-only, 用于FTP POP3

    curl ftp://ftcurl ftp://ftp.isc.org/isc/ -l -vp.isc.org/isc/ -l -v

     

  14.  



posted @ 2022-05-13 13:40  ascertain  阅读(27)  评论(0编辑  收藏  举报