来自批处理文件的http Web请求

Tho*_*ker 11 batch-file httpwebrequest

我需要从Plesk的Task Scheduler执行一个http Web请求(在Windows/ASP.NET上使用共享主机;无论如何都没有Powershell).考虑为此使用批处理文件.

是否有捷径可寻?

Her*_*rms 18

看看卷曲.它是一个用于发出Web请求的跨平台命令行工具(如果您之前使用过,则类似于wget).您应该可以从批处理文件中调用它.


npo*_*aka 17

没有外部二进制文件 - 只有内置的Windows功能 - > https://github.com/npocmaka/batch.scripts/blob/master/hybrids/jscript/winhttpjs.bat

这是jscript/.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
Run Code Online (Sandbox Code Playgroud)

头文件格式应该如下(如果使用-header命令参数传递):

Header-1: Value-1
ExampleHeader: Value2
Run Code Online (Sandbox Code Playgroud)

  • 简单又好看.我在无法安装exes的情况下应用了这个. (2认同)