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

[µo°Ý] Selenium

[µo°Ý] Selenium



½Ð±Ð§Ú­n§ì¹Ï¤¤ªººñ¦â³¡¥÷(§t­Ë¤T¨¤§Î),«ç»ò§ì(»yªk)?
https://tw.stock.yahoo.com/quote/2330
±qºô­¶±oª¾FindElementByXPath
//*[@id="qsp-overview-realtime-info"]/div[2]/div[2]/div/ul/li[8]/span[2]
³o¬O­Ë¤T¨¤§Î§t¼Æ¦r
//*[@id="qsp-overview-realtime-info"]/div[2]/div[2]/div/ul/li[8]/span[2]/span
³o¥u¦³­Ë¤T¨¤§Î

¦^´_ 12# singo1232001

   ÁÂÁ«ü¾É¡A §Ú¸Õ¸Õ¬Ý¯à§ä¥X¬Æ»ò¡C

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-8-30 09:09 ½s¿è

¦^´_ 11# Scott090


§â§ä¤¸¯À·Q¹³¦¨,¸òÀÉ®×Á`ºÞ§ä¸ê®Æ§¨¤@¼Ë
±`¥Îªº¦³¤÷¤lÃö«Y ¥S§ÌÃö«Y ©ÎªÌID°ß¤@©Ê
¦Ó¤÷¤¸¯À ¦³ªº¥ÎID ¦³ªº¥Îtag  ¦³ªº¬O¶¶¦ì ¦³ªº¥Î°Æ¥[ÄÝ©Êattribute
³o4ºØ¤è¦¡¥i¥H¨ó§U§A§ä¨ì»Ý­nªº¤÷¤¸¯À ©Î ¤l¤¸¯À
·í¤U¬Ý¬Ý¨º¨Ç¤è¦¡¾A¦X¨Ï¥Î
³q±`¥Î©óºô­¶¦³²§¨Bªº±¡ªp ¤~·|»Ý­n¶¶µÛÃö«Y©Î°fµÛÃö«Y§ä
­Yºô­¶¨S²§¨B ´N¤£¥ÎÃö«Y§ä ª½±µ¥ÎbyXpath§¹¾ã¸ô®|§ä¨ì´N¥i¥H
´N¦p¦P ª½±µ½Æ»s¸ê®Æ§¨¸ô®|¨º¼Ë ´N¯à«e©¹¸ê®Æ§¨¦ì¸m
³q±`¯à¸Ñ¨M80~90%´M§ä°ÝÃD

¸É¥R:
ÁÙ¥i¯à¹J¨ìifram¦³®Ø¬[ºô¯¸
ÁÙ¥i¯à¹J¨ì»Ý­n¥Îexecuteª`¤Jcss ¸Ñ¨M³Ñ¤U10~20%¨ä¥L¦³¹ï¤¸¯À°Ê¤â¸},ºô¯¸©Ê¯S®í«OÅ@ªº°ÝÃD

TOP

¦^´_ 10# singo1232001

     ·P®¦¸Ô¸Ñ¡C
      
   ½Ð«ü¾É¤@¤U¦bÂsÄý¾¹ ¥Î"¶}µoªÌ¤u¨ã"  :
     ¦b³o­Ó¨Ò¤l¤¤¬°¤°»òª¾¹D­n§ä
     Id("quote-summary")
     tag("tbody")
      tag("tr")
     tag("td")
    ?

TOP

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

TOP

¦^´_ 8# t8899

    ½Ð°Ý¦p¦ó¦b¦¹ºô­¶ "https://finance.yahoo.com/quote/TSM/"
        ¨ú±o¤U¦C³o¤@¨Ç¸ê®Æ ?  
    ÁÂÁÂ

   Previous Close        549.00
Open        551.00
Bid        552.00 x 0
Ask        553.00 x 0
Day's Range        546.00 - 553.00
52 Week Range        370.00 - 594.00
Volume        10,650,708
Avg. Volume        22,277,577

TOP

¦^´_ 7# singo1232001

ÁÂÁ«ü¾É

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-8-24 18:13 ½s¿è

¦^´_ 6# t8899


Sub ®É¶¡¤º¨S¥[¸ü§¹´Nºâ¥¢±Ñ()
t = Timer '´ú¸Õ¥Î¥i§R
Set driver = CreateObject("selenium.chromedriver")
driver.Timeouts.pageload = 10000 '­n¬O¬í¼Æ¹L§C ¨S¥[¸ü§¹ ´N·|±j¨îÃö³¬ ¥i¥H¸ÕµÛ´ú¸Õ3¬í¥H¤U
On Error Resume Next
driver.get "https://finance.yahoo.com/quote/TSM/"
If Err.Number <> 0 Then
Err.Clear
driver.Quit
End If
On Error GoTo 0
Debug.Print Timer - t  '´ú¸Õ¥Î¥i§R
End Sub




¦]¬°¤£¾å±o§Aªº»Ý¨D
©Ò¥H§Ú¶¶«K§â­«³s¤T¦¸ªº¼gªk¤]µ¹§A

Sub ­«³s¤T¦¸¨C¦¸µ¥¤T¬í_²Ä¥|¦¸´N¥¢±Ñ()
Set driver = CreateObject("selenium.chromedriver")
On Error Resume Next
Do
driver.Get "https://finance.yahoo.com111111111/quote/TSM/"
If Err.Number <> 0 Then
    Err.Clear
    Application.Wait Now + TimeValue("00:00:03")
    rT = rT + 1
    If rT = 3 Then driver.Quit: Exit Do
Else
    Exit Do
End If
Loop
On Error GoTo 0
End Sub

TOP

¦^´_ 4# singo1232001

drIVER.get "https://finance.yahoo.com/quote/TSM/"
½Ð±Ð¦pªG³s½u¶W¹L3¬í¦³°ÝÃD?«h¸õ¥Xªº»yªk?

TOP

¦^´_ 4# singo1232001

ÁÂÁ«ü¾É

TOP

        ÀR«ä¦Û¦b : §ïÅܦۤv¬O¦Û±Ï¡A¼vÅT§O¤H¬O±Ï¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD