I am trying to extract the HTML Page Source of a given URL as a String. I found the code below which works but for some reason doesn't work all the time (it gives various different errors sporadically).
Public Function gsGetPageSource(URLToCrawl As String) As String
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
Do While .Busy And Not .ReadyState = 4
gsGetPageSource = IIf(StrComp(.Document.Title, "Cannot find server", vbTextCompare) = 0, vbNullString, .Document.Body.outerHTML)
Set ie = Nothing