.bat文件实现一个简单的http请求工具(支持get和post请求)

利用win10支持curl命令的原理,构造参数发送请求
在这里插入图片描述

代码:

@echo off
:again
set /p web=please input web url: 
set /p method=please input method: 
if %method%==PUT (goto :TransferData) else (if %method%==POST (goto :TransferData) else (curl -v -X %method% -H "Content-Type: text/html; charset=UTF-8" %web%))
goto :again
pause

:TransferData
set /p data=please input data: 
curl -v -X %method% -H "Content-Type: text/html; charset=UTF-8" -d %data% %web%
goto :again

成品运行截图:

在这里插入图片描述

posted @ 2022-09-20 14:56  明金同学  阅读(137)  评论(0)    收藏  举报  来源