【问题标题】:VBA Proxy auto-configuration for http requests用于 http 请求的 VBA 代理自动配置
【发布时间】:2015-09-13 04:08:12
【问题描述】:

我需要在 VBA 中为 Web api 构建一个客户端,它需要在代理后面工作(带有身份验证)。我一直在研究 WinHttp.WinHttpRequest 和 MSXML2.XMLHTTP/ServerXMLHTTP 类。原来:

  • XMLHTTP 自动检测通过 proxy.pac 文件提供的代理设置(好)
  • WinHttpRequest 没有(坏)

但是,另一方面:

  • XMLHTTP 自动跟随重定向,并且有 no way 禁用此行为(不好)
  • WinHttpRequest 没有(好)

既然我想吃蛋糕,有没有办法为 WinHttpRequest 等不盲目跟随重定向的组件自动配置代理?

【问题讨论】:

    标签: vba excel


    【解决方案1】:

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-06
      • 2020-01-04
      • 1970-01-01
      • 2015-02-25
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 2017-09-02
      相关资源
      最近更新 更多