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.
    
  • 相关阅读:
    升级Nginx1.14.1以上版本
    MaxScale中间件部署数据库读写分离
    php文件锁解决少量并发问题
    使用mysql悲观锁解决并发问题
    配置和查看composer镜像
    PHP常用的 五种设计模式及应用场景
    全球免费公共 DNS 解析服务器 IP 地址列表推荐 (解决无法上网/加速/防劫持)
    九种跨域方式实现原理
    Hadoop中RPC协议小例子报错java.lang.reflect.UndeclaredThrowableException解决方法
    DataNode启动不成功——java.net.BindException: Port in use: localhost:0 Caused by: java.net.BindException: Cannot assign requested address解决办法
  • 原文地址:https://www.cnblogs.com/Searchor/p/13717694.html
Copyright © 2011-2022 走看看