ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Selenium

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-7-20 11:57 ½s¿è

¦^´_ 1# t8899


¦pªG§A¥Îxpath ´N¬O³o¼Ë
Sub tttt()
Set driver = CreateObject("Selenium.ChromeDriver")
driver.get "https://tw.stock.yahoo.com/quote/2330"
driver.Wait 1000

Set xp = driver.findelementbyxpath("//*[@id=""qsp-overview-realtime-info""]/div[2]/div[2]/div/ul/li[8]")
      Set sn = xp.findelementsbytag("span")

Select Case True
Case sn(2).Attribute("class") Like "*C($c-trend-up)*": tx = "¡¶ "
Case sn(2).Attribute("class") Like "*C($c-trend-down)*": tx = "¡¿ "
Case Else: tx = " - "
End Select
Debug.Print sn(1).Text & " " & tx & " " & sn(2).Text
  
Stop
End Sub

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-7-20 11:05 ½s¿è

¦^´_ 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

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-7-20 03:01 ½s¿è

¦^´_ 1# t8899


<div class="Jc(fe) Mend(4px) Fw(600) D(f) Ai(c) C($c-trend-up)"   ' ³o¬O¬õ¦â¦V¤W
<div class="Jc(fe) Mend(4px) Fw(600) D(f) Ai(c) C($c-trend-down)"  '³o¬Oºñ¦â ¦V¤U


©Ò¥H   
if  ºô­¶¤¸¯Àª«¥ó.Attribute("class") Like "*C($c-trend-up)*" Then
debug.print "¡¶"  '¥¿¼Æ
else
debug.print "¡¿"  '­t¼Æ
end if


§A¤]¥i¥H¸ÕµÛ¤@­Ó¤@­Ó
debug.print  ºô­¶¤¸¯Àª«¥ó.Attribute("class")  
Æ[¹î¬O¤£¬O§A­nªº

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¤Hªº§Ö¼Ö¡D¤£¬O¦]¬°¥L¾Ö¦³±o¦h¡A¦Ó¬O¦]¬°¥L­p¸û±o¤Ö¡C
ªð¦^¦Cªí ¤W¤@¥DÃD