感覺 .ResponseText 內容好多啊!
其實我不需要選擇日期,只需要抓當前日期 Chinese Equity Fund, Global Bond Fund和Hang Seng Index Tracking Fund 三種基金的當前價格。是否可能抓少一些東西讓.ResponseText內容少些呢?作者: DanielWONG 時間: 2018-6-17 09:01 標題: VBA自動抓取finance.yahoo
Sub 香港交易所_test()
Dim Stock1 As String
Dim oXmlhttp As Object, oHtmldoc As Object, surl As String, E As Object, R As Integer, C As Integer
Set oXmlhttp = CreateObject("msxml2.xmlhttp")
Set oHtmldoc = CreateObject("htmlfile")
surl = "https://hk.finance.yahoo.com/quote/0388.HK"
With oXmlhttp
.Open "Get", surl, False
.send
oHtmldoc.Write .responseText
End With
ActiveSheet.Cells.Clear
With oHtmldoc
Set E = .all.tags("table")(1)
For R = 0 To E.Rows.Length - 1
For C = 0 To E.Rows(R).Cells.Length - 1
ActiveSheet.Cells(R + 1, C + 1) = E.Rows(R).Cells(C).innerText
Next
Next
End With
End Sub作者: iamaraymond 時間: 2018-6-17 15:06