zoukankan      html  css  js  c++  java
  • curl

    参考:https://blog.csdn.net/chengxuyuanyonghu/article/details/54970073

    带token的get请求实例: curl -G  -H 'Authorization: Token bc7776046ec74fad6569ba0c8a95c3b0f708acbe' http://localhost:8080/aaa/bbb/ccc/get_works/ -d job_id=37

    通过代理访问:-x ,如:curl -x 10.207.107.205:3128 www.baidu.com

    -G/--get 以get的方式来发送数据,例如:
    curl -G poc:8080/poc/v1/device/mast/measurement -d wfids=632523 -d stime=2017-11-24%00:00:00 -d etime=2017-11-24%2001:00:00

    --resolve HOST:PORT:ADDRESS 将 HOST:PORT 强制解析到 ADDRESS,例如:

    curl --resolve mywebsite.com:80:192.168.18.3 http://mywebsite.com/demo  或 curl -H 'Host:mywebsite.com' http://192.168.18.3/demo 

    curl -k https://192.168.18.3/demo/ 
    可以通过 --data/-d 方式指定使用POST方式传递数据
    例如:发送post请求:curl -d "title=HAHA" -d "tag=python" http://localhost:5000/api/post
    或者通过-X指定方法:如:
    curl -l -H "Content-type: application/json" -X POST -d '{"phone":"12345678900","password":"test"}' "http://www.test.com"

    通过POST方式传递过去的数据中若有特殊字符,首先需要将特殊字符转义再传递给服务器端,如value值中包含有空格,则需要先将空格转换成%20,如:
    curl -d "value%201" http://hostname.com

    在新版本的CURL中,提供了新的选项 --data-urlencode,通过该选项提供的参数会自动转义特殊字符,
    如:curl --data-urlencode "value 1" http://hostname.com

    如果要把这个网页保存下来,可以使用-o参数,这就相当于使用wget命令了。
    curl -o [文件名] www.baidu.com


    # 将myfile.txt文件上传到服务器 :curl -u ftpuser:ftppass -T myfile.txt ftp://ftp.testserver.com
    # 下载xss.php文件 : curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/xss.php
    在访问需要授权的页面时,可通过-u选项提供用户名和密码进行授权:curl -u username:password URL

    通过-o/-O选项保存下载的文件到指定的文件中:
    -o:将文件保存为命令行中指定的文件名的文件中
    -O:使用URL中默认的文件名保存文件到本地
    curl -o mygettext.html http://www.gnu.org/software/gettext/manual/gettext.html
    curl -O http://www.gnu.org/software/gettext/manual/gettext.html

    GET方法相对简单,只要把数据附在网址后面就行: curl baidu.com/form.cgi?data=xxx

    POST方法必须把数据和网址分开,例如:
    curl -d "method=searchone&module=seller&user_name=wb-liqiu&nickname=dd" -H"Host:fmp.view.lz.taobao.com" "10.235.160.141:8082/api.php"

    ==========================

  • 相关阅读:
    BCD与ASCII码互转-C语言实现
    <<用法
    linux无锁化编程--__sync_fetch_and_add系列原子操作函数
    C中的volatile用法
    c++ k^1
    linux ftp使用相关
    linux应用程序启动时加载库错误问题
    kafka消费者脚本无法启动问题
    Django框架简介
    前端基础之Bootstrap
  • 原文地址:https://www.cnblogs.com/testzcy/p/13129816.html
Copyright © 2011-2022 走看看