来自批处理文件的http Web请求
-
05-07-2019 - |
题
我需要从Plesk的Task Scheduler执行http Web请求(在Windows / ASP.NET上使用共享主机;无论如何都没有Powershell)。考虑使用批处理文件。
有一种简单的方法吗?
解决方案
查看卷曲。它是一个用于发出Web请求的跨平台命令行工具(如果您之前使用过,则类似于wget)。您应该可以从批处理文件中调用它。
其他提示
没有外部二进制文件 - 只有内置的Windows功能 - > https://github.com/npocmaka/batch。脚本/斑点/主/合体/ JScript的/ winhttpjs.bat
这是 jscript / .bat
hybrid,可以像简单的bat一样调用。
示例用法(我已将 http://requestb.in/ 用于测试目的):
call winhttpjs.bat "http://requestb.in/xxxxxx" -method POST -header hdrs.txt -reportfile reportfile2.txt
call winhttpjs.bat "http://requestb.in/xxxxxx" -method GET -header hdrs.txt -reportfile reportfile3.txt -saveTo c:\somezip.zip
call winhttpjs.bat "http://requestb.in/xxxxxx" -method POST -header hdrs.txt -reportfile reportfile2.txt -saveTo responsefile2 -ua "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" -body-file some.json
头文件格式应如下(如果使用 -header
命令参数传递):
Header-1: Value-1
ExampleHeader: Value2
您可以尝试使用 wget for Windows 。
您允许安装哪些 ?例如,您可以使用 wget for Windows 吗?或者编写.NET可执行文件,使用WebClient或HttpWebRequest来完成您需要的所有操作?
“卷曲” utiliity基本上是一个精彩的libcurl库的命令行包装器,它几乎可以处理任何http请求或响应。它免费免费提供。
不隶属于 StackOverflow