美文网首页
curl学习记录

curl学习记录

作者: wasw100 | 来源:发表于2015-10-30 18:03 被阅读0次

-s, —slient

沉默模式, 不显示具体的过程, 看一下有没有这个参数的区别

xyz@mac:~ > curl -o /dev/null www.baidu.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 96551    0 96551    0     0  58649      0 --:--:--  0:00:01 --:--:-- 58657
xyz@mac:~ > curl -o /dev/null -s www.baidu.com
xyz@mac:~ >

-w, --write-out <format>

例如我要获取返回远程网站的状态码以及ip可以这么获取

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

-m, --max-time <seconds>

          Maximum time in seconds that you allow the whole operation to take. 设置超时时间

> curl www.google.com.hk -m 1
curl: (28) Connection timed out after 1003 milliseconds

-x, --proxy <[protocol://][user:password@]proxyhost[:port]>

          Use the specified proxy. 使用代理

-i, --include

          (HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...

获取的内容包括响应头

-I, --head

          (HTTP/FTP/FILE)  Fetch  the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on an FTP or FILE file, curl dis-

          plays the file size and last modification time only.

只获取http响应头, 使用http的HEAD方法请求

curl -x 127.0.0.1:8888 -I www.baidu.com

-L, --location

自动跳转

curl -I -L baidu.com/a

-v, --verbose

获取通信的详细过程

--trace <file>

更详细的请求信息:

-d, --data <data>

使用post发送请求信息

--data-urlencode <data>

对data数据进行编码

curl -x 127.0.0.1:8888 --data "q=apple" http://dict.youdao.com/search

-X, --request <command>

使用不同的请求方式, 例如使用post方式请求baidu

curl -X POST www.baidu.com

-F, --form <name=content>

上传文件

如果是文件

-F, --form <name=content>

curl -x 127.0.0.1:8888 -F "web=@output.txt;type=text/html" -F name=xyz url.com

—header, —referer, —cookie, —user-agent 都看字面意思就知道作用了

相关文章

  • curl学习记录

    -s, —slient 沉默模式, 不显示具体的过程, 看一下有没有这个参数的区别 -w, --write-out...

  • Curl记录

    man网址: https://curl.haxx.se/docs/manpage.html[https://cur...

  • curl命令记录

    网上搬来的curl的实用方法 关于更多curl中可以使用的变量信息请参考:curl变量参考

  • Linux curl 命令get/post 详解

    最近工作频繁使用curl命令,加深了对curl有关post json 格式,及json数据大的问题,以此记录。 c...

  • 【ES】CURL在windows中对ElasticSearch的

    上一节说了CURL在windows中的安装方式,现在就简单的记录下CURL在windows中对ElasticSea...

  • Curl-用法记录

    -i : 显示响应中的HTTP头 -X: 指定请求HTTP方法 curl -i -X OPTIONS 192.16...

  • curl命令学习

    curl是非常方便的Rest 客户端, 可以很方便的完成 Rest API测试, 利用curl对http协议发送G...

  • curl简单使用

    对于http调试,curl是一个很好用的工具,本篇文章主要记录curl日常的使用方法。 访问url 最基本的使用方...

  • php curl https ssl 证书问题

    CURL代码: $curl=curl_init(); curl_setopt($curl,CURLOPT_URL,...

  • 得到外网ip

    Curl 输出 curl JSON格式输出: 使用 Wget 代替 Curl curl XML格式输出: curl...

网友评论

      本文标题:curl学习记录

      本文链接:https://www.haomeiwen.com/subject/wzvfhttx.html