zoukankan      html  css  js  c++  java
  • linux之curl

    一、官方解读:

     curl is a tool to transfer data from or to a server, 

    using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS,  LDAP,  LDAPS,  POP3,  POP3S,  RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP).

    The command is designed to work  without user interaction.

    curl offers a busload of (一系列) useful tricks like proxy support, user authen-tication, FTP upload, HTTP post, SSL connections, cookies, file  trans- fer  resume,  Metalink,  and more.

    As you will see below, the number of features will make your head spin!

     

      如上内容中重点如下:

      (1)curl是用来传输数据到server或从server获取数据存储到本地

      (2)其支持的协议包括:DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS,  LDAP,  LDAPS,  POP3,  POP3S,  RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP

      (3)能够完成:代理支持、用户认证、ftp文件上传、http post、SSL连接、cookies、文件等的传输。

     

    常用方式:

      (1)获得页面内容(百度首页是页面,内容会以html返回)

        curl http://www.baidu.com

     

     

      (2)获得页面内容并以文件形式存储

        curl -o index.html http://www.baidu.com

      (3)若网页有重定向,加-L能获取最终的页面内容

        curl -L http://www.baidu.com

      (4)若网络不稳定,加-C能断点续传

        curl -c -o cookiec.txt http://www.linux.com

      (5)发起application/json请求

    curl 
        -b 'uin=o123456789; skey=@tq9xjRvYy' 
        -H 'Content-Type: application/json'
        -X POST 
        -d 'param={"id":"id"}' 
        http://localhost:8080/test
    
     -b是设置cookie参数 -H指定支持数据的格式
    
    curl 
        -H 'Content-Type: application/json'
        -X POST 
        -d 'param={"id":"1"}' 
        http://localhost:8080/test

     更多用法:

      https://www.cnblogs.com/gbyukg/p/3326825.html

      https://blog.csdn.net/cmzsteven/article/details/73382333

  • 相关阅读:
    JAVA实现DES加密实现详解
    CentOS 7安装Hadoop 3.0.0
    使用JAVA开发微信公众平台(一)——环境搭建与开发接入
    Oracle触发器用法实例详解
    负载均衡中使用 Redis 实现共享 Session
    在windows上部署使用Redis
    java 线程排查问题流程
    使用Fernflower 比较准确的反编译整个java项目
    Mysql用户本机登陆不成功的解决
    kali 系统的源
  • 原文地址:https://www.cnblogs.com/chendeming/p/9329677.html
Copyright © 2011-2022 走看看