zoukankan      html  css  js  c++  java
  • linux-curl工具使用

    环境:centos

    1、超时参数解析

    #使用curl时,有两个超时时间:
    #--connect-timeout <seconds>     是连接超时时间
    #-m/--max-time     <seconds>     是整个过程允许的最大时间 
    #下面表示连接百度20秒没有连接到百度退出,整个过程40s没有返回退出
    curl --connect-timeout 20 -m 40 https://www.baidu.com
    

    2、静默不输出信息 -s 参数

    [root@minion246 wj]# curl http://gayd.sczwfw.gov.cn:8903|grep mess                     #不带-s
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100    62  100    62    0     0   1444      0 --:--:-- --:--:-- --:--:--  1476
    {"code":40966,"message":"请求的应用token位数不正确"}
    [root@minion246 wj]# curl -s http://gayd.sczwfw.gov.cn:8903|grep mess                 #带参数-s
    {"code":40966,"message":"请求的应用token位数不正确"}
    

    3、获取对方的响应首部信息 -I

    [root@minion246 wj]# curl -I http://gayd.sczwfw.gov.cn
    HTTP/1.1 200 OK
    Vary: Accept-Encoding
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Methods: GET,HEAD,PUT,POST,DELETE
    Content-Type: text/plain; charset=utf-8
    Content-Length: 0
    Date: Wed, 23 Sep 2020 03:16:25 GMT
    Connection: keep-alive
    

    4、显示网页的全部信息

    curl -i  "https://www.baidu.com" 
    

    5、显示一次的http请求的通信过程

    [root@minion246 wj]# curl -v http://gayd.sczwfw.gov.cn
    * About to connect() to gayd.sczwfw.gov.cn port 80 (#0)
    *   Trying 202.61.88.250...
    * Connected to gayd.sczwfw.gov.cn (202.61.88.250) port 80 (#0)
    > GET / HTTP/1.1
    > User-Agent: curl/7.29.0
    > Host: gayd.sczwfw.gov.cn
    > Accept: */*
    

    6、模拟get 请求

    当发起http请求时,curl会默认发起GET请求,也可以"-X GET"方式指定
    curl -X GET http://www.baidu.com
    

    7、模拟post提交

    1、有body参数
    curl -d "param1=value1&param2=value2" "http://www.baidu.com"
    2、有JOSN格式的body和header入参
    curl -s -l -H "Content-type: application/json" -X POST -d @/wj/smrz.xml https://gayd.sczwfw.gov.cn/e62894182afb55c9a65baab9ba9b6d18
    

      

    做一个决定,并不难,难的是付诸行动,并且坚持到底。
  • 相关阅读:
    多线程频繁上锁同步还不如用单线程
    1分钟左右随机生成2000万行随机字符串
    语言:抽象,封装,底层,低级
    构建WDK驱动出现fatal error U1087: cannot have : and :: dependents for same target
    Cmake编译成静态库
    VMware虚拟机相关文件问题
    输出流重定向
    How can I let the compiled script depend on something dynamic
    应用服务攻击工具clusterd
    Kali Linux缺少ifconfig命令
  • 原文地址:https://www.cnblogs.com/wukc/p/13717121.html
Copyright © 2011-2022 走看看