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

标签 batch-file httpwebrequest

我需要从 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/

相关文章:

batch-file - 7zip 使用批处理文件创建空文件

用于下载项目的 C# 代码,检查文本/二进制和 gzip/非压缩?

asp.net - 从 ASP.Net 页面将 NetworkCredential 传递给 C# 中的 HttpWebRequest

for-loop - 带有填充数字的/L 循环

batch-file - “@echo off”和“@echo%off”之间的区别?

arrays - 设置多维数组批处理

asp.net - 长时间运行的 HttpWebRequest

c# - 尝试单击按钮登录网站(Httpwebrequest - cookies)

c# - CookieContainer混淆

windows - 强制 Windows 批处理脚本返回代码 0