zoukankan      html  css  js  c++  java
  • CURL 笔记

    官网地址:https://curl.haxx.se/

    CURL是服务器之间传递数据的工具,支持大多数协议,如我们熟知的FTP,FTPS,HTTP,HTTPS, IMAP,SMTP, TELNET等等。他可以用于获取网站数据,

    也可以上传数据。

    简单用法:

    1. 获取百度的网页内容,这个会返回html。

      curl https:www.baidu.com

    2. 获取网站某个端口所返回的内容。比如:8080

      curl http://www.xxx.com:8080/

    3. 获取server上的文件

      curl ftps://files.xx.com/a.txt

    4. 爬取百度首页的html并将其保存到local的某个文件,使用 curl -o 命令

      curl -o baidu.html https://www.baidu.com

    5. 传递authentication头,比如用户名和密码

      curl -u username:password http://www.xx.com

    6. curl -v 打印额外信息,这个可以看到请求头和响应头

      curl -v https://www.baidu.com

    7. 发送post请求。 curl -d , 使用application/x-www-form-urlencoded MIME类型。

      curl -d "name=foo&pass=1234" http://www.xx.com

    8. 上传文件 curl -F

      curl -F "file=@test.txt" http://www.xx.com

    9. 设置referrer, curl -e

      curl -v -e  http://www.cnblogs.com/ https://www.baidu.com

    10. 传递cookie, curl -b

      curl -b "name=foo" http://www.xx.com

  • 相关阅读:
    python 类
    hdu 5761 Rowe Bo 微分方程
    calendar 示例
    hdu 5753 Permutation Bo
    hdu 5752 Sqrt Bo
    finally 语句
    throws 和 throw
    python打开.pkl的文件并显示里面的内容
    Python 类变量,成员变量,静态变量,局部变量
    python 实例方法,类方法,静态方法,普通函数
  • 原文地址:https://www.cnblogs.com/gogolee/p/6883261.html
Copyright © 2011-2022 走看看