Fetching webpage source when the response is diffe

2019-09-17 09:09发布

问题:

With my code (given below), I capture source of my website's webpage and then I am trying to find a string with InStr and process it with Split. Everything is working but I have an issue where I need help.

When I am logged in to my website supplying the username and password, I can see the string in the webpage source but when I am in a logged out state, my string is not visible in the webpage source. What changes do I need in the code which will tell the computer that I am logged in.

Is this a cache/cookies issue? if yes, how to code it so that it honors the browser cache/cookies remembering that the user is logged in and gets the source as it shows up in logged in state?

Appreciate a reply. Thanks

Sub source()
    Dim oHttp As New WinHttp.WinHttpRequest
    Dim sURL As String
    Dim webpageSource As String
    sURL = "http://www.google.com"
    oHttp.Open "GET", sURL, False
    oHttp.send
    webpageSource = oHttp.ResponseText
End Sub