zoukankan      html  css  js  c++  java
  • curl基于URL的文件传输工具

    简介

    cURL是一款开源的基于URL的文件传输工具,支持HTTP、HTTPS、FTP等协议,支持POST、cookie、认证、扩展头部、限速等特性。

    curl命令用途广泛,比如下载、发送http请求、指定http头部等。

    wget是个专职的下载利器,简单,专一,极致;而curl可以下载,但是长项不在于下载,而在于模拟提交web数据,对请求报文进行设置,从而对网页进行调试。

    wget支持递归下载,curl不支持。所以区分下来就是下载数据使用wget,网页调试使用curl。

    常用功能

    curl URL     #下载文件到stdout
    curl URL -s/--silent    #安静模式,不显示过程也不显示报错
    curl URL --silent --progress   #显示#号的进度条
    curl URL --silent -O  #下载数据写入文件,文件名和URL中文件名相同
    curl URL --silent -o filename   #手动指定文件名
    curl URL -C offset   #从指定偏移量位置继续下载,offset是字节为单位的整数
    curl URL -C -     #断点续传
    curl URL --referer referer_URL    #指定参照页字符串
    curl URL --cookie "user=peter;pass=123456"   #手动指定并存储cookie
    curl URL --cookie-jar cookie_file   #从文件中指定cookie
    curl URL --user-agent "Mozilla/5.0"   #指定用户代理
    curl URL -H "Host: www.peter.com" -H "Accept-language: en"   #设置多个http头部信息
    curl URL --limit-rate 20k   #限制下载速度
    curl URL --max-filesize bytes    #指定可下载的最大文件大小
    curl URL -u user:pass    #进行密码认证
    curl URL -I    #只打印响应头部信息
    curl URL -k    #--insecure 接受不安全的数字证书,例如自签名证书
    curl URL -S    #--show-error 显示报错,一般curl URL -sS 连用
    curl URL -x    #--proxy <[protocol://][user:password@]proxyhost[:port]> 使用代理服务器
    curl URL -D    #--dump-header <file> 将响应头部信息写入某个文件 一般存储cookie就是存储header
    curl URL -b    #--cookie <name=data> 使用本地cookie,一般是"NAME1=VALUE1; NAME2=VALUE2"键值对格式,也可以 -b <file> 使用cookie文件
    curl URL -d    #--data <data> 使用POST方法提交数据  通常提交方式是键值对,例如curl URL -d 'user=name' -d 'password=passwd' ,这里注意curl
                   #会将多个-d参数后面的内容组合成'name=daniel&skill=lousy'这种形式,所以我们自己也可以使用curl URL -d 'name=name&password=passwd'
                   #形式提交数据; 第二种方法是读取文件数据进行提交例如 curl URL -d @filename 
    curl URL -X    #--request <command>  指定请求方法例如curl URL -X POST
    
  • 相关阅读:
    hdu2860 并查集模拟
    hdu 3938 Portal离线并查集
    hdu 2489 Minimal Ratio Tree (DFS枚举+MST)
    hdu 3172 并查集+map
    hdu 1829 A Bug's Life 并查集系列
    hdu 1598 find the most comfortable road
    HDU1198
    【Oracle】【17】表创建后,对表进行操作(添加字段,删除主键约束等)
    【JS】【19】使用Jquery判断是电脑或手机或微信浏览器访问
    【JS】【18】当前时间加减一天和格式化时间格式
  • 原文地址:https://www.cnblogs.com/Peter2014/p/7596888.html
Copyright © 2011-2022 走看看