发送GET请求
使用curl指令
普通请求:
curl -i/I/v http://www.yanxiaohui.cn
(如果请求的地址为文件,会直接下载至本地.其中,i代表显示全部信息,I代表显示头部信息,v代表解析请求全过程,默认为i)
带参数请求:
curl -v http://www.yanxiaohui.cn?param1=1\¶m2=2
(get请求携带的参数只到param1=1,”&”符号在linux系统中为后台运行的操作符,此处需要使用反斜杠”\”转义)
使用wget指令
wget http://www.yanxiaohui.cn
发送POST请求
使用curl指令
curl -d "username=user1&password=123" "http://www.yanxiaohui.cn/login"
(通过-d参数,把访问参数放在里面,如果没有参数,则不需要-d)
发送格式化json请求
curl -i -k -H "Content-type: application/json" -X POST -d '{"version":"6.6.0", "from":"mu", "product_version":"1.1.1.0"}' http://www.yanxiaohui.cn
使用wget指令
wget –post-data 'username=user1&password=123' http://www.yanxiaohui.cn
curl会将请求结果输出在终端中,而wget将请求结果保存在文件中