- 帖子
- 533
- 主題
- 58
- 精華
- 0
- 積分
- 613
- 點名
- 239
- 作業系統
- win 10
- 軟體版本
- []
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2013-3-19
- 最後登錄
- 2026-9-30
             
|
回復 52# singo1232001
再請教 大大, 下一程式如何填加功能取得 "資料時間 : 2023/08/21 10:44", 謝謝
http://forum.twbts.com/viewthread.php?tid=23777&page=4
Sub Test()
Dim Driver As New Selenium.ChromeDriver
Dim ID0 As Object, UL1
Dim sp, u2%, ar(), i%, w%
Dim sh As Worksheet
Cells.ClearContents
Set Driver = CreateObject("Selenium.ChromeDriver")
If Driver Is Nothing Then opDriver
Driver.AddArgument ("headless") '不顯示WebPage
' Driver.Start
Driver.Get "https://tw.stock.yahoo.com/quote/1101.TW"
Set ID0 = Driver.FindElementByID("qsp-overview-realtime-info")
Set UL1 = ID0.FindElementsByTag("ul")(1)
'單列
sp = Split(UL1.text, Chr(10))
Cells(1, 1).Resize(UBound(sp) + 1, 1) = Application.Transpose(sp)
'雙列
u2 = UBound(sp) / 2
ReDim ar(1 To u2, 1 To 2)
For i = 0 To UBound(sp) Step 2
w = w + 1
ar(w, 1) = sp(i)
ar(w, 2) = sp(i + 1)
Next
Cells(1, 3).Resize(UBound(ar), 2) = ar
End Sub |
|