水下功夫做透,水上才能顺风顺水。

curl 命令

curl命令的get请求:curl URL

curl http://mywebsite.com/index.php?a=1\&b=2\&c=3

url 为 http://mywebsite.com/index.php?a=1&b=2&c=3,web(浏览器)形式下访问url地址,使用$_GET是可以获取到所有的参数  然而在linux下  curl http://mywebsite.com/index.php?a=1&b=2&c=3  $_GET只能获取到参数a  。

由于url中有&,其他参数获取不到,在linux系统中& 会使进程系统后台运行  必须对&进行下转义才能$_GET获取到所有参数  curl http://mywebsite.com/index.php?a=1\&b=2\&c=3

curl命令的post请求(1):curl -d "args"  URL

curl -d "a=1&b=2&c=3 " http://mywebsite.com/index.php

这种方法是参数直接在header里面的,如需将输出指定到文件可以通过重定向进行操作.

curl命令的post请求(2):curl -H "Content-Type:application/json" -X POST -d 'json data' URL

这种方法是json数据直接在body里面的

 

posted @ 2018-10-29 16:18  北方寒士  阅读(265)  评论(0编辑  收藏  举报