Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,075
- Office Version
- 2019
- Platform
- Windows
I have watch many tutorials on this HTML subject, but I'm not understanding why this code is not working. I'm trying to get the Bid Price, and the code runs without error, but prints nothing. What am I doing wrong??? Very Frustrated!!! Please help. Thank you kindly.
the URL: https://finance.yahoo.com/quote/DIS181123C00101000?p=DIS181123C00101000
the URL: https://finance.yahoo.com/quote/DIS181123C00101000?p=DIS181123C00101000
Code:
Sub GetRate()'*******************************************************************************
'Set references to:
'Microsoft Internet Controls
'Microsoft HTML Object Library
'Microsoft XML, v6.0
'Hit Alt+F11 to go to the Visual Basic Editor and then hit:
'Tools | References
'*******************************************************************************
Dim XMLPage As New MSXML2.XMLHTTP60
Dim htmlDoc As New MSHTML.HTMLDocument
Dim URL As String
Dim HTMLspans As MSHTML.IHTMLElementCollection
Dim HTMLspan As MSHTML.IHTMLElement
Dim titleElem As Object
Dim topic As HTMLHtmlElement
URL = "https://finance.yahoo.com/quote/DIS181123C00101000?p=DIS181123C00101000"
XMLPage.Open "GET", URL, False
XMLPage.send
htmlDoc.body.innerHTML = XMLPage.responseText
Set HTMLspans = htmlDoc.getElementsByTagName("Bxz(bb) Bdbw(1px) Bdbs(s) Bdc($c-fuji-grey-c) H(36px) ")
For Each HTMLspan In HTMLspans
If HTMLspan.className = "Ta(end) Fw(b) Lh(14px)" Then
Debug.Print HTMLspan.innerText
End If
Next HTMLspan
End Sub