我编写了以下代码来获取网站的innerHTML文本:
Public Function GetInnerHtmlBody(ByVal Url As String) As HTMLDocument
Dim ResponseDocument As New HTMLDocument
Dim MyRequest As New WinHttpRequest
With MyRequest
.SetTimeouts 5000, 5000, 5000, 5000
.SetProxy HTTPREQUEST_PROXYSETTING_PROXY, "<PROXY_SERVER_IP>:<PORT>", "*.domain.com"
.Open "GET", Url, False
'// Authentication for the proxy server
'.SetCredentials "<USERNAME>", "<PASSWORD>", CREDENTIALS_FOR_PROXY
.Send
'// Debug
MsgBox .ResponseText, vbInformation, .StatusText & " - " & .Status
ResponseDocument.body.innerHTML = .ResponseText
End With
Set GetInnerHtmlBody = ResponseDocument
End Function
正如您所看到的,.SetCredentials
行被注释掉了。这行只需要一次通过代理服务器进行身份验证,但现在似乎保存了登录凭据,因为即使我排除了代码,代码也会成功检索给定网站的html代码。
我重新启动计算机并清除了整个IE缓存,但代码仍然有效。
我的问题是Credentials
保存在哪里? Coockie?
有没有办法让HttpRequest使用IE代理设置? - &GT;无需询问用户名和密码。