- 帖子
- 354
- 主題
- 5
- 精華
- 0
- 積分
- 387
- 點名
- 0
- 作業系統
- windows7
- 軟體版本
- vba,vb,excel2007
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2017-1-8
- 最後登錄
- 2024-8-2
 
|
3#
發表於 2023-7-20 11:04
| 只看該作者
本帖最後由 singo1232001 於 2023-7-20 11:05 編輯
回復 1# t8899
Sub ttt()
Set driver = CreateObject("Selenium.ChromeDriver")
driver.get "https://tw.stock.yahoo.com/quote/2330"
driver.Wait 1000
Set ID_0 = driver.findelementbyID("qsp-overview-realtime-info")
Set ID_0_ul_S = ID_0.findelementsbytag("ul")
Set ID_0_ul_S_1_li_S = ID_0_ul_S(1).findelementsbytag("li")
For i = 1 To ID_0_ul_S_1_li_S.Count
Set x = ID_0_ul_S_1_li_S(i).findelementsbytag("span")
If x(1).Text Like "*漲跌*" Then
Select Case True
Case x(2).Attribute("class") Like "*C($c-trend-up)*": tx = "▲ " & x(2).Text
Case x(2).Attribute("class") Like "*C($c-trend-down)*": tx = "▼ " & x(2).Text
Case Else: tx = x(2).Text
End Select
Debug.Print x(1).Text & " " & tx
Else
Debug.Print x(1).Text & " " & x(2).Text
End If
Next
Stop
End Sub |
|