我需要在 VBA 中为 Web api 构建一个客户端,并且它需要在代理后面工作(带有身份验证)。我一直在研究 WinHttp.WinHttpRequest 和 MSXML2.XMLHTTP/ServerXMLHTTP 类。事实证明:
然而,另一方面:
既然我希望能够鱼与熊掌兼得,有没有办法为像 WinHttpRequest 这样不盲目遵循重定向的组件获取自动代理配置?
VBA-Web 项目可能会帮助您解决糕点食用问题。
https://github.com/VBA-tools/VBA-Web
我想你想做的事情会是这样的:
Dim client As New WebClient
With client
.BaseUrl = "https://www.google.com"
.ProxyUsername = <user>
.ProxyPassword = <password>
.EnableAutoProxy = True
End With
Dim request As New WebRequest
With request
.Method = WebMethod.HttpGet
.Format = WebFormat.PlainText
End With
Dim response As WebResponse
Set response = client.Execute(request)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4827 次 |
| 最近记录: |