zoukankan      html  css  js  c++  java
  • curl base

    下载

    指定下载文件名,已存在同名文件被覆盖

    curl -o filename.ext downloadlink
    

    继续现有下载

    curl -O -C downloadlink
    

    检测下载文件是否存在,不下载

    curl -I https://www.booleanworld.com/
    

    自动重定向

    curl -L http://example.com
    

    最多700次重定向

    curl -L --max-redirs 700 example.com
    

    无限次

    curl -L --max-redirs -1 example.com
    

    cURL can only follow redirects if the server replied with a HTTP redirect, which means that the server used a 3XX status code, and it used the Location header to indicate the new URL

    查看res http header

    curl -i http://example.com
    

    verbose mode

    curl -v http://example.com
    
    • the output contains request data (marked with >)

    • response headers (marked with <)

    • other details about the request, such as the IP used and the SSL handshake process (marked with *).

    忽略res body

    curl -vo /dev/null https://www.booleanworld.com/ # Linux/MacOS
    curl -vo NUL https://www.booleanworld.com/ # Windows
    

    忽略进度条以及错误

    curl -svo /dev/null https://www.booleanworld.com/ # Linux/MacOS
    curl -svo NUL https://www.booleanworld.com/ # Windows
    

    忽略进度条,保留错误

    curl -sSvo /dev/null https://www.booleanworld.com/ # Linux/MacOS
    curl -sSvo NUL https://www.booleanworld.com/ # Windows
    

    只忽略进度条,其他信息保存到文件

    curl -sSvo file.html https://www.booleanworld.com/
    

    处理错误

    访问网站出错时,curl返回0

    curl https://www.booleanworld.com/404 -sSo file.txt
    

    访问网站出错时,curl返回非0

    curl https://www.booleanworld.com/404 -fsSo file.txt
    

    检测协议版本

    curl -v --tlsv1.2 https://www.booleanworld.com/
    
    curl -v --sslv3 https://www.booleanworld.com/
    
    --sslv<version> 
    --tlsv<version>
    --http1.0
    --http1.1
    --http2
    

    时间

    curl https://www.baidu.com/ -sSo /dev/null -w 'namelookup:	%{time_namelookup}
    connect:	%{time_connect}
    appconnect:	%{time_appconnect}
    pretransfer:	%{time_pretransfer}
    redirect:	%{time_redirect}
    starttransfer:	%{time_starttransfer}
    total:		%{time_total}
    '
    
    namelookup — The time required for DNS resolution.
    connect — The time required to establish the TCP connection.
    appconnect — This is the time taken to establish connections for any layers between TCP and the application layer, such as SSL/TLS. In our case, the application layer is HTTP. Also, if there is no such intermediate layer (such as when there is a direct HTTP request), this time will always be 0.
    pretransfer — This is the time taken from the start to when the transfer of the file is just about to begin.
    redirect — This is the total time taken to process any redirects.
    starttransfer — Time it took from the start to when the first byte is about to be transferred.
    total — The total time taken for cURL to complete the entire process.
    
  • 相关阅读:
    CJSon使用
    mqtt学习-3 编译运行测试
    mqtt学习-2 创建c vs项目
    mqtt学习-1 Mqtt服务器搭建
    Linux c 开发-5 使用VsCode远程调试Linux程序
    Layui数据表格之获取表格中所有的数据方法
    layui 给数据表格加序号的方法
    Layui关闭弹出层并刷新父页面,父页面向子页面传值
    MUI中小数点的数字输入框,步进step为小数时的需求和浮点数的精确问题
    MUI-numbox(数字输入框),最小值、最大值、步长、获取值、设置值、重定义
  • 原文地址:https://www.cnblogs.com/Searchor/p/13717694.html
Copyright © 2011-2022 走看看