網站:
https://www.wantgoo.com/stock/astock/agentstat2?stockno=2330
Sub test()
Cells.Clear
Dim myXML As Object
Set myXML = CreateObject("Microsoft.XMLHTTP")
Dim myHTML As Object
Set myHTML = CreateObject("HTMLFile")
stockno = InputBox("輸入股號")
Dim t: t = Timer
With myXML
.Open "GET", "https://www.wantgoo.com/stock/astock/agentstat2?stockno=" & stockno, False
.send
myHTML.body.innerHTML = .responseText
Set myTable = myHTML.getElementsByTagName("table")(0)
ReDim myArr(1 To myTable.Rows.Length, 1 To myTable.Rows(0).Cells.Length)
i = 1
For Each myRow In myTable.Rows
j = 1
For Each myCell In myRow.Cells
myArr(i, j) = myCell.innerText
j = j + 1
Next
i = i + 1
Next
End With
Range("A3").Resize(UBound(myArr, 1), UBound(myArr, 2)).Value = myArr
Set myXML = Nothing
Set myHTML = Nothing
Erase myArr
Range("A2") = stockno
Application.StatusBar = "下載完畢,共花了" & Format(Timer - t, "0.00秒")
End Sub
作者已經移除這則留言。
回覆刪除