VBS 中的 HTTP GET
有没有办法在 Visual Basic 脚本中执行 HTTP GET 请求? 我需要从特定 URL 获取响应内容进行处理。
Is there a way to perform an HTTP GET request within a Visual Basic script? I need to get the contents of the response from a particular URL for processing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在撰写本文时,您尚未描述您将如何处理该响应或其内容类型。 答案已经包含
MSXML2.XMLHTTP
的非常基本的用法(我建议使用更明确的MSXML2.XMLHTTP.3.0
progID),但是您可能需要对响应执行不同的操作,它可能不是文本。XMLHTTP 还有一个
responseBody
属性,它是响应的字节数组版本,并且有一个responseStream
,它是响应的IStream
包装器。请注意,在服务器端需求(例如,托管在 ASP 中的 VBScript)中,您将使用
MSXML.ServerXMLHTTP.3.0
或WinHttp.WinHttpRequest.5.1
(它们具有几乎相同的功能)界面)。以下是使用 XmlHttp 获取 PDF 文件并存储它的示例:-
You haven't at time of writing described what you are going to do with the response or what its content type is. An answer already contains a very basic usage of
MSXML2.XMLHTTP
(I recommend the more explicitMSXML2.XMLHTTP.3.0
progID) however you may need to do different things with the response, it may not be text.The XMLHTTP also has a
responseBody
property which is a byte array version of the reponse and there is aresponseStream
which is anIStream
wrapper for the response.Note that in a server-side requirement (e.g., VBScript hosted in ASP) you would use
MSXML.ServerXMLHTTP.3.0
orWinHttp.WinHttpRequest.5.1
(which has a near identical interface).Here is an example of using XmlHttp to fetch a PDF file and store it:-
如果您使用 GET 请求实际发送数据...
检查:
http://techhelplist.com /index.php/tech-tutorials/37-windows-troubles/60-vbscript-sending-get-request
MSXML2.XMLHTTP 的问题是它有多个版本,根据 Windows 的不同,其名称也不同操作系统版本和补丁。
这解释了它:
http://support.microsoft.com/kb/269238
我有更多的运气使用 vbscript打电话
......还有更多的事情,但只是为了让请求通过。
If you are using the GET request to actually SEND data...
check:
http://techhelplist.com/index.php/tech-tutorials/37-windows-troubles/60-vbscript-sending-get-request
The problem with MSXML2.XMLHTTP is that there are several versions of it, with different names depending on the windows os version and patches.
this explains it:
http://support.microsoft.com/kb/269238
i have had more luck using vbscript to call
....and more stuff but just to let the request go thru.