Excel 股市資料抓取服務

提供Excel 股市資料抓取服務
可透過下列方式聯絡我
Email: iamaraymond@yahoo.com.tw
(FB請先加我好友再私訊,不然會跑到陌生訊息)

課程:
Excel VBA 金融資料抓取 | 打造股票研究系統 (學生數: 602,學員評價5顆星)
無痛起步-Excel VBA超入門實戰(學生數: 413,學員評價5顆星)


2018年6月5日 星期二

Excel VBA 抓取玩股網 近30日主力進出動向

玩股網 30日主力進出動向

網站:
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

1 則留言: