我无法访问span
标记并抓取“1天总回报”的内部文字。
这是网页:
http://www.morningstar.com/funds/XNAS/DODFX/quote.html
这是我的代码
Sub Macro1()
'
link = "http://www.morningstar.com/funds/XNAS/DODFX/quote.html"
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate link
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Dim doc As HTMLDocument
Set doc = ie.document
While ie.readyState <> 4
Wend
On Error Resume Next
Application.Wait (Now + TimeValue("00:00:02"))
range("B5").Offset(0, 0).Value = doc.getElementById("msqt_summary")(0).getElementsByClassName("gr_colm_a2b")(0).getElementsByTagName("span")(0).innerText
End With
ie.Quit
Application.EnableEvents = True
'
End Sub
答案 0 :(得分:0)
这是您获取数据的方式。数据确实在iframe内。
-0.67
输出:
{{1}}