Ok so here is my entire code:
Private Sub CommandButton1_Click()
Dim appIE As Object
Set appIE = CreateObject("internetexplorer.application")
With appIE
.Navigate "http://finance.yahoo.com/q/ks?s=" & "AAPL"
.Visible = True
End With
Do While appIE.Busy
DoEvents
Loop
Set getPrice = appIE.Document.getElementById("yfs_l84_aapl")
Dim myValue As String: myValue = getPrice.Cells(1).innerHTML
appIE.Quit
Set appIE = Nothing
Range("B1").Value = myValue
End Sub
And here is the HTML that I'm trying to read into Excel (specifically, I need the 113.92):
<span id="yfs_l84_aapl">113.92</span>
What do I have to change in these two lines of code to read a "span id"?
Set getPrice = appIE.Document.getElementById("yfs_l84_aapl")
Dim myValue As String: myValue = getPrice.Cells(1).innerHTML
Or, alternatively, is there a way just to read whatever is directly after "yfs_184"??
I'm brand new to coding and am working very hard to get better, so any help is really appreciated!! Thanks! :)
用这个:
myValue = getPrice.innerText
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.