I have the following code using Internet Explorer which allows the page to load until the word "Fair Value" appears in the final HTML (which I then want to extract):
Dim t As Date,
Const MAX_WAIT_SEC As Long = 3 '<==Adjust wait time
myFile = ActiveWorkbook.Path & "\Downloads\FinBox.html"
If FileExists(myFile) Then Kill myFile
Set oIE = New InternetExplorer
myUrl="h t t p s : / / finbox.com/NASDAQGS:AMZN/models/dcf-growth-exit-10yr"
oIE.navigate myUrl
oIE.Visible = True
Do
Loop Until oIE.readyState = READYSTATE_COMPLETE
oIE.Refresh
While oIE.Busy Or oIE.readyState < 4: DoEvents: Wend
t = Timer
Do
DoEvents
On Error Resume Next
HTMLDoc.Body.innerHTML = oIE.document.Body.innerHTML
sPageHTML = HTMLDoc.Body.innerHTML
If InStr(LCase(sPageHTML), "fair value") > 0 Then ftextFound = True
If Timer - t > MAX_WAIT_SEC Then Exit Do
On Error GoTo 0
Loop While ftextFound = False
If ftextFound = True Then
fileNo = FreeFile
Open myFile For Output As #fileNo
Print #fileNo, sPageHTML
Close #fileNo
End If
Since I believe that Internet Explorer will no longer be supported in Windows 11, can someone provide code that will mimic this functionality using "MSXML2.XMLHTTP.6.0"or similar in VBA?
I do have Selenium installed, so similar code for that would also be acceptable.
The idea is that it is a dynamic page which takes a few seconds to completely load, so just getting the .responseText is not sufficient.
Thanks.
Bookmarks