- ©«¤l
- 354
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 387
- ÂI¦W
- 0
- §@·~¨t²Î
- windows7
- ³nÅ骩¥»
- vba,vb,excel2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-1-8
- ³Ì«áµn¿ý
- 2024-8-2
|
¦^´_ 9# Scott090
Sub test()
Set driver = CreateObject("selenium.chromedriver")
driver.get "https://finance.yahoo.com/quote/TSM/"
Do: Set ids = driver.findelementsbyId("quote-summary")
If ids.Count > 0 Then Exit Do
Loop
Do: Set tby = ids(1).findelementsbytag("tbody")
If tby.Count > 0 Then Exit Do
Loop
Debug.Print tby(1).Text
Set trs = tby(1).findelementsbytag("tr")
ReDim ar(1 To trs.Count, 1)
For i = 1 To trs.Count
Set tds = trs(i).findelementsbytag("td")
ar(i, 0) = tds(1).Text
ar(i, 1) = tds(2).Text
Next
Cells.ClearContents
Range("a1").Resize(UBound(ar), 2) = ar
End Sub |
|