返回列表 上一主題 發帖

[發問] 抓網頁表格?

[發問] 抓網頁表格?

https://tw.stock.yahoo.com/adr
Sub adr()
    Set Ie = CreateObject("InternetExplorer.Application")
'  Ie.Visible = True
       Ie.Navigate "https://tw.stock.yahoo.com/adr"
Do While Ie.Busy Or Ie.ReadyState <> 4: DoEvents: Loop
    Dim I As Integer, S As Integer, k As Integer, J As Integer
     Dim Element
    Set Element = Ie.document.getelementsbytagname("table")
    With Sheets("sheet1")
            For S = 0 To 5               
            For I = 0 To Element(S).Rows.Length - 1
                k = k + 1
                For J = 0 To Element(S).Rows(I).Cells.Length - 1
                 .Cells(k, J + 1) = Element(S).Rows(I).Cells(J).innerText
                Next
            Next
        Next
    End With
    Set Element = Nothing
Ie.Quit
End Sub

回復 2# lee88

感謝指導

TOP

        靜思自在 : 信心、毅力、勇氣三者具備,則天下沒有做不成的事。
返回列表 上一主題