我需要从 Plesk 的 Task Scheduler 执行 http web 请求(使用 Windows/ASP.NET 上的共享主机;没有 Powershell,无论如何)。考虑为此使用批处理文件。
是否有捷径可寻?
最佳答案
没有外部二进制文件 - 只有内置的 Windows 功能 -> https://github.com/npocmaka/batch.scripts/blob/master/hybrids/jscript/winhttpjs.bat
这是 jscript/.bat
混合,可以像简单的 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
不支持多部分请求(尽管我计划添加这样的功能(某天))
关于batch-file - 来自批处理文件的 http Web 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/420646/