Excel VBA WinHttpRequest saved Credentials

2.6k views Asked by At

I wrote the following code to get the innerHTML text of a website:

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

As you can see the line .SetCredentials is commented out. This line was only needed once to authenticate with the proxy server but now it seems like the login credentials were saved, because even if i exlude the row the code successfully retrieves the html code of the given website.

I restartet my computer and cleared the whole IE cache but the code still works.

  1. My question is now where are the Credentials saved? Coockie?

  2. Is there a way that the HttpRequest uses the IE proxy settings? -> No need of asking for Username and Password.

0

There are 0 answers