• 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.
    
  • 相关阅读:
    SSM(六)JDK动态代理和Cglib动态代理
    SSM(三)Mybatis动态SQL
    MyBatis无限级分类实现的两种方法--自关联与map集合
    idea上MyBatis第一个例子
    idea 给maven项目添加依赖(二)
    idea 创建maven项目(一)
    Java学习笔记——三层架构
    MySQL实现自动使用uuid作为主键以及解决不能调用触发器的一点思路
    Java学习笔记——MySQL创建表结构
    jQuery入门——注册事件
  • 原文地址:https://www.cnblogs.com/Searchor/p/13717694.html
Copyright © 2020-2023  润新知