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

[µo°Ý] ¥ÎSelenium §ì¤W¥«¦æ±¡§Y®É¸ê®Æ ???

¦^´_  t8899


    ³oºô¯¸api¦n¹³¦³2ºØ­­¨î

1ºØ¬O¦¸¼Æ­­¨î  §Ú¥Î¨â¤äªÑ²¼ ¤â°Ê½Æ»sºô§} ¤j·§³sÄò¬í¬d ...
singo1232001 µoªí©ó 2022-10-25 17:47

§Ú¤S´ú¤F¤@¤U¡Aºô¯¸5¬í§ó¤@¦¸ ¨S°ÝÃD (¥Î1°¦´ú)
§Ú´ú99°¦´ú²Ä¤G¦¸´N·|¥X²{¿ù»~ ?«Ü©úÅ㦳­­¨î¬dªº¼Æ¶q

TOP

¦^´_  t8899


    ³oºô¯¸api¦n¹³¦³2ºØ­­¨î

1ºØ¬O¦¸¼Æ­­¨î  §Ú¥Î¨â¤äªÑ²¼ ¤â°Ê½Æ»sºô§} ¤j·§³sÄò¬í¬d ...
singo1232001 µoªí©ó 2022-10-25 17:47

³o­Óºô¯¸­­¨î¤Ó¦h¡A³Ì¥D­n¦¨¥æ»ù¤K¦¨¬OªÅªº¡A¥u¯à¬Ý5Àɸ̪º²Ä¤@­Ó¶R½æ2¿ï¤@µLªk½T©w¹ê»Ú¦¨¥æ»ù¡A¥u¦n±Ë±ó

https://tw.stock.yahoo.com/class ... =2&exchange=TAI
³o¬Ý°_¨Ó¬O¤@­Ótable? §Ú¥Î FindElementByXPath §ä¤£¨ì¥¦ªº¸ô®|?

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-10-28 18:42 ½s¿è

¦^´_ 42# t8899


¥Îbytag ¦Ó¥B³oºô­¶§Ú¤§«eª±¹L

¥t¥~´N¬O¤W­±´£¨ìªº ³oºô­¶«á­±¤£·|¤@¦¸¶]¥X¨Ó
¥u¯à¥Îtag ¸òµe­±²¾°Ê±±¨î ¨ÓÅý«á­±ªº¶]¥X¨Ó
¥Lªº¶µ¥Ø¤£¬O¤@¯ëtable ¦Ó¬O¥Îclass¶]¥X¨Ó

»Ý­n¥Î find..s..tag+§PÂ_+°j°é+µ¥«Ý ¦s¦b¨Ó³v¨B¦V¤º§ä§ó¤º¼hªº¤¸¯À ¦³ÂI²ö¦Wªº¹³¬OÀÉ®×Á`ºÞ¤@ª½¶}¤l¸ê®Æ§¨¨º¼Ë


Àɮ׬O5.6¤ë¥ª¥k¼g±o,¯à¤£¯à°Ê §Ú¤£¤Ó²M·¡ ¤]¨S¥h­×§ï

ºô­¶ª¦ÂÎv1.zip (52 KB)

TOP

¥»©«³Ì«á¥Ñ t8899 ©ó 2022-10-28 21:13 ½s¿è
¦^´_  t8899


¥Îbytag ¦Ó¥B³oºô­¶§Ú¤§«eª±¹L

¥t¥~´N¬O¤W­±´£¨ìªº ³oºô­¶«á­±¤£·|¤@¦¸¶]¥X¨Ó
¥u¯à¥Î ...
singo1232001 µoªí©ó 2022-10-28 18:32

Sub kimo()
Application.ScreenUpdating = False
Set DRIVER = CreateObject("Selenium.ChromeDriver")
DRIVER.AddArgument ("headless") 'µLÀYµøµ¡
DRIVER.Get "https://tw.stock.yahoo.com/class-quote?sectorId=2&exchange=TAI"
Set dd = DRIVER.FindElementByXPath("//*[@id=""main-1-ClassQuotesTable-Proxy""]/div/div[3]/div/div/div[2]")
Range("a:K").Clearcontents
Range("a1:k1") = Array("ªÑ²¼¦WºÙ", "¥N¸¹", "ªÑ»ù", "º¦¶^", "º¦¶^´T(%)", "¶}½L", "¬Q¦¬", "³Ì°ª", "³Ì§C", "¦¨¥æ¶q(±i)", "®É¶¡")
a = split(dd.Text, Chr(10))
b = UBound(a)
   k = 11
   s = 2
   g = 1
For i = 0 To b
     If i = k Then
     k = k + 11
     s = s + 1
     g = 1
        End If
     Cells(s, g) = a(i)
    g = g + 1
    Next
End Sub
table ¿é¥X¸û§Ö?¥i±¤¥¦¤£¬Otable
¶^ªº¤U¤T¨¤§Î¨S§ì¨ì?¦p¦óª½±µ§ï¦¨"-"¸¹¿é¥X?

TOP

¦^´_ 35# singo1232001


    ¦¹ÀÉ seleniumdownload v9.zip->seleniumdownload v9.xlsm
   ³Q windows defender ÀË¥X«Â¯Ù Trojan:O97M/Sadoca.C!ml
    ½Ð½T»{¡C

    ÁÂÁÂ

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-4-17 01:51 ½s¿è

¦^´_ 45# Scott090


¤w´ú¸Õ ÀɮרS°ÝÃD
»Ý­n³]©w¨¾¬r ·s¼W±Æ°£¶µ¥Ø §â³o­ÓÀɮױư£¦b¨¾¬r¤§¥~

­è°µ¤F¥æ¤e´ú¸Õ

À³¸Ó¬O¤U­±³o¬qsub ¦]¬°¦³½Õ¥Î¨ìshell(CMD)  ¦Û°Ê°õ¦æ ¤U¸ü+¸ò¸ÑÀ£ÁY+§RÀÉ ´N³Q³Q§P©w´c·Nµ{§Ç
Sub updataSelenium()  '¦Û°Ê§ó·sselenium
path1 = "C:\Users\" & Environ$("username") & "\AppData\Local\SeleniumBasic\Chromedriver.exe"
path2 = "C:\Program Files\SeleniumBasic\chromedriver.exe"
If Dir(path1) <> "" Then TempDrvFile = path1
    'Kill (TempDrvFile)  '°²¦p¦b¿ù»~ªº±¡ªp¤U §ä¨ì¤FÀÉ®× ¨º¤§«á±N­n§ó·s½Æ»sÂл\ ÁקK¸õ¥X½Æ»s¤w¦s¦b¿ù»~ĵ§i ©Ò¥H¥ý§R°£±¼
If Dir(path2) <> "" Then TempDrvFile = path2
foler = Left(TempDrvFile, InStrRev(TempDrvFile, "\"))


Set objHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")  'Get chrome version
chrversion = CreateObject("WScript.Shell").RegRead("HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon\version")
dotsarr = Split(chrversion, ".")
leftchrver = dotsarr(0) & dotsarr(1)


Set oShell = CreateObject("wscript.shell")
errcode = oShell.Exec(TempDrvFile & " --version").StdOut.ReadAll
verarr = Split(errcode, " ")
chrdrv = verarr(1)
dotsarr2 = Split(chrdrv, ".")
leftchrdrv = dotsarr2(0) & dotsarr2(1)
If leftchrver = leftchrdrv Then Exit Sub


Url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_" & dotsarr(0)
Call objHttp.Open("GET", Url, False)
Call objHttp.Send("")
version_number = objHttp.responseText
dotsarr3 = Split(version_number, ".")
leftversion_no = dotsarr3(0) & dotsarr3(1)
download_url = "https://chromedriver.storage.googleapis.com/" + version_number + "/chromedriver_win32.zip"
   
    Call objHttp.Open("GET", download_url, False)
    Call objHttp.Send("")
        

        Set fileStream = CreateObject("ADODB.Stream")
        With fileStream
            .Open
            .Type = 1 'adTypeBinary
            .Write objHttp.responseBody
            .Position = 0
            .SaveToFile foler & "chromedriver.zip", 2 '                   "C:\Program Files\SeleniumBasic\chromedriver.zip", 2  'adSaveCreateOverWrite 'adSaveCreateOverWrite
            .Close
        End With
        
        '¸ÑÀ£ÁY        'C:\Program Files\SeleniumBasic
        On Error GoTo 0
        Set oApp = CreateObject("Shell.Application")
        If Dir(TempDrvFile) <> "" Then Kill TempDrvFile
        oApp.Namespace(foler).CopyHere _
            oApp.Namespace(foler & "chromedriver.zip").items

End Sub

¤W­±³o¬q¬O ¬d¸ßgoogle chrome§ó·sª©¥»¸¹
¦A±qselenium©xºô ¤U¦A³Ì·s§ó·sÀÉ
¦Û°Ê§ó·schromedriver.exe§ó·sªº¦Û°Êµ{§Ç
¨Ã¥B§R°£Âªºchromedriver.exe
¨S³o¬q ´N¥²¶·¤â°Ê§ó·s

¤]¥i¥H´ú¸Õ
­Yª½±µ§â³o¥÷ÀÉ®× ¥á¨ìgoogle¶³ºÝ ¶}¦@¨É ¨ê·s ¤]·|¸õºX¤l(¦³«Â¯Ù©ÊÀÉ®×)
¦pªG§A½Æ»s¤@¥÷ÀÉ®× §â¤W­±¨º¬q³£§R¤F ¦A¥á¨ìgoogle¶³ºÝ ´N¨S¤ÏÀ³¤F

¸É¥R
­Y¬O¤U¸ü«á ¥´¶}¤£°õ¦æªº±¡ªp ¤S¬O¥t¤@ºØ±¡ªp
ÀÉ®×>¥kÁä>¤º®e> ¸Ñ°£«ÊÂê

TOP

¦^´_ 46# singo1232001

ÁÂÁ½T»{´ú¸Õ»P«ü¤Þ

TOP

¦^´_ 46# singo1232001

  ½Ð°Ý¤j¤j¡A
    ChromeDriver ¦Û115.0ª© °_¡A ´Á§ó·s¤w¤£©ñ¦b
          https://chromedriver.storage.googleapis.com/LATEST_RELEASE_
    ¦Ó©ñ¦b
          https://googlechromelabs.github.io/chrome-for-testing/#stable

   46¼Óªº  µ{¦¡¸Ó¦p¦ó­×¹¢¡G
Sub updataSelenium()  '¦Û°Ê§ó·sselenium
   .........................
    Url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_" & dotsarr(0)
Call objHttp.Open("GET", Url, False)
Call objHttp.Send("")
version_number = objHttp.responseText
dotsarr3 = Split(version_number, ".")
leftversion_no = dotsarr3(0) & dotsarr3(1)
download_url = "https://chromedriver.storage.googleapis.com/" + version_number + "/chromedriver_win32.zip"
   
    Call objHttp.Open("GET", download_url, False)
    Call objHttp.Send("")
        

        Set fileStream = CreateObject("ADODB.Stream")
        With fileStream
            .Open
            .Type = 1 'adTypeBinary
            .Write objHttp.responseBody
            .Position = 0
            .SaveToFile foler & "chromedriver.zip", 2 '                   "C:\Program Files\SeleniumBasic\chromedriver.zip", 2  'adSaveCreateOverWrite 'adSaveCreateOverWrite
            .Close
        End With
        
        '¸ÑÀ£ÁY        'C:\Program Files\SeleniumBasic
        On Error GoTo 0
        Set oApp = CreateObject("Shell.Application")
        If Dir(TempDrvFile) <> "" Then Kill TempDrvFile
        oApp.Namespace(foler).CopyHere _
            oApp.Namespace(foler & "chromedriver.zip").items
End sub   

    ·PÁÂ

TOP

¦^´_ 46# singo1232001

  ½Ð°Ý¤j¤j¡A
    ChromeDriver ¦Û115.0ª© °_¡A ´Á§ó·s¤w¤£©ñ¦b
          https://chromedriver.storage.googleapis.com/LATEST_RELEASE_
    ¦Ó©ñ¦b
          https://googlechromelabs.github.io/chrome-for-testing/#stable

   46¼Óªº  µ{¦¡¸Ó¦p¦ó­×¹¢¡G
Sub updataSelenium()  '¦Û°Ê§ó·sselenium
   .........................
    Url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_" & dotsarr(0)
Call objHttp.Open("GET", Url, False)
Call objHttp.Send("")
version_number = objHttp.responseText
dotsarr3 = Split(version_number, ".")
leftversion_no = dotsarr3(0) & dotsarr3(1)
download_url = "https://chromedriver.storage.googleapis.com/" + version_number + "/chromedriver_win32.zip"
   
    Call objHttp.Open("GET", download_url, False)
    Call objHttp.Send("")
        

        Set fileStream = CreateObject("ADODB.Stream")
        With fileStream
            .Open
            .Type = 1 'adTypeBinary
            .Write objHttp.responseBody
            .Position = 0
            .SaveToFile foler & "chromedriver.zip", 2 '                   "C:\Program Files\SeleniumBasic\chromedriver.zip", 2  'adSaveCreateOverWrite 'adSaveCreateOverWrite
            .Close
        End With
        
        '¸ÑÀ£ÁY        'C:\Program Files\SeleniumBasic
        On Error GoTo 0
        Set oApp = CreateObject("Shell.Application")
        If Dir(TempDrvFile) <> "" Then Kill TempDrvFile
        oApp.Namespace(foler).CopyHere _
            oApp.Namespace(foler & "chromedriver.zip").items
End sub   

    ·PÁÂ

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2023-8-20 19:47 ½s¿è

¦^´_ 49# Scott090

¥»¤H¤£¬O«Ü±M·~ ¦Û¤v¤]¨S§â´¤¥i¥H100%¨S°ÝÃD
¥[¤W¤£ª¾¹D¤§«á¦³¨º¨Çºô§}»P»yªk¬O©T©wªº
©Ò¥H¥i¥H¥ý±N´N¥Î¬Ý¬Ý

    Sub updataSelenium()
'¥Ñ©óselenium¦³¥i¯à·|¦w¸Ë¦bwindows¤U¨â­Ó¨ä¤¤¤@­Ó¸ê®Æ§¨¤¤ ©Ò¥H­n¥ý§ä¥X¸ê®Æ§¨¦ì¸m (mac¥Ø«e¥¼¦Ò¼{)
path1 = "C:\Users\" & Environ$("username") & "\AppData\Local\SeleniumBasic\Chromedriver.exe"
path2 = "C:\Program Files\SeleniumBasic\chromedriver.exe"
If Dir(path1) <> "" Then TempDrvFile = path1
If Dir(path2) <> "" Then TempDrvFile = path2
foler = Left(TempDrvFile, InStrRev(TempDrvFile, "\")) '¨ú±o ¸ê®Æ§¨¸ô®| »P chromedrive.exe ¸ô®|

'Àò¨ú·í«echromedriverª©¥»«e¨â½X ¨Ò: 117.0
Set oShell = CreateObject("wscript.shell")
errcode = oShell.Exec(TempDrvFile & " --version").StdOut.ReadAll
verarr = Split(errcode, " ")
chrdrv = verarr(1)
dotsarr2 = Split(chrdrv, ".")

'Àò¨úchrome·í«eÂsÄý¾¹ª©¥»¸¹     ¨Ò: 117.0
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")  'Get chrome version
chrversion = CreateObject("WScript.Shell").RegRead("HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon\version")
dotsarr = Split(chrversion, ".")
leftchrver = dotsarr(0) & dotsarr(1)

'¤ñ¹ïchromedriver »P chromeÂsÄý¾¹ ¨â­Óª©¥»¸¹, ¬Û¦P(¤£§ó·s) ; ¤£¦P(¤W©xºô¬dÂsÄý¾¹³Ì·sª©¥»¸¹ ¨ÃÄ~Äò¤U¸ü¸ÑÀ£¨ú¥N)
leftchrdrv = dotsarr2(0) & dotsarr2(1)
If leftchrver = leftchrdrv Then Exit Sub

'¨ì©xºôapiÀò¨úª©¥»¸ê°T ¨Ã©î¸Ñ¸ê°T ¸Ó¸ê°T¬°json®æ¦¡ ¨ÃÀò±o·í«eÂsÄý¾¹¥i¥Îªºchromedriverª©¥»¸¹
'¥»json©îªk¬°¯S»s ¤£²Å¦X¥¿³Wjson ¤£ª¾¹D¥¼¨Óªº®æ¦¡·|¤£·|ÅÜ ¦]¬°¤£·Q¤Þ¥ÎÃB¥~ª«¥ó
Url = "https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone.json"
Call objHTTP.Open("GET", Url, False)
Call objHTTP.Send("")
version_number = objHTTP.responseText
v0 = Split(version_number, ",""milestones"":{")
v1 = Split(v0(1), "},")
For i = 0 To UBound(v1)
v1(i) = Replace(v1(i), """", "")
v1(i) = Replace(v1(i), ":{milestone:", ",")
v1(i) = Replace(v1(i), ",version:", ",")
v1(i) = Replace(v1(i), ",revision:", ",")
v1(i) = Replace(v1(i), "}}}", ",")
Next
ReDim v2(UBound(v1))
For i = 0 To UBound(v1): v2(i) = Split(v1(i), ","): Next
For i = 0 To UBound(v2)
If v2(i)(0) = dotsarr(0) Then: version_number = v2(i)(2): Exit For
Next

'¥Í¦¨³sµ²ºô§}  (¥t¶·ª`·N¿ï¾Ü§@·~¨t²Î¦ì¤¸ ¦b¤U¤ècmd³B ¤]¦³»Ý­n­×§ïªº³¡¤À)  ¤£ª¾¹D¥¼¨Óºô§}·|¤£·|ÅÜ
'download_url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/" & version_number & "/linux64/chromedriver-linux64.zip"
'download_url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/" & version_number & "/mac-x64/chromedriver-mac-x64.zip"
'download_url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/" & version_number & "/win32/chromedriver-win32.zip"
download_url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/" & version_number & "/win64/chromedriver-win64.zip"
    Call objHTTP.Open("GET", download_url, False)
    Call objHTTP.Send("")

        Set fileStream = CreateObject("ADODB.Stream")  '¨Ï¥Îadodb.stream ±µ¨üÀÉ®×
        With fileStream
            .Open
            .Type = 1 'adTypeBinary
            .Write objHTTP.responseBody
            .Position = 0
            .SaveToFile foler & "chromedriver.zip", 2 '  ¤U¸üÀɮרìselenium¸ê®Æ§¨    ' 2  adSaveCreateOverWrite
            .Close
        End With
        
        '¨Ï¥Îshell+cmd±þªºÀÉ®×   killªº¤è¦¡³Q·L³n«Ê¤F
        Set oApp = CreateObject("Shell.Application")
        cmdCommand = "cmd /c del " & foler & "chromedriver.exe"     '¨Ï¥Îcmd§R°£ÀÉ®× cmd /c del "path"
        Call Shell(cmdCommand, vbHide)                             '±þ±¼Âªºchromedriver.exe
        cmdCommand = "cmd /c del " & foler & "LICENSE.chromedriver"
        Call Shell(cmdCommand, vbHide)                             '±þ±¼ÂªºLICENSE.chromedriver
            '­Y¨S±þ¦¨¥\ ¸Óµ{§Ç¨SÃö³¬ µLªk§R°£®É ±N°õ¦æ¦î¦C¤¤ªºÀÉ®×Ãö³¬  'cmd /c taskkill /F /IM chromedriver.exe ¬O±þ¦î¦C
            If Dir(foler & "chromedriver.exe") <> "" Then
            cmdCommand = "cmd /c taskkill /F /IM chromedriver.exe && cmd /c del " & foler & "chromedriver.exe"  '±þ±¼Âªºchromedriver.exe
            Call Shell(cmdCommand, vbHide)
            End If
            If Dir(foler & "LICENSE.chromedriver") <> "" Then
            cmdCommand = "cmd /c taskkill /F /IM LICENSE.chromedriver && cmd /c del " & foler & "LICENSE.chromedriver"  '±þ±¼ÂªºLICENSE.chromedriver
            Call Shell(cmdCommand, vbHide)
            End If
            
        '±N·sªºchromedriver.exe¸ÑÀ£ÁY¨ì¸ê®Æ§¨¤¤  16¬O±j¨î¨ú¥N¿ï¶µ ª`·NÀ£ÁYÀɤºªºÀɦW ·|¦]¨t²Î¦ì¤¸¤£¦P¸ê®Æ§¨¤£¦P
        oApp.Namespace(foler).CopyHere _
            oApp.Namespace(foler & "chromedriver.zip\chromedriver-win64").items, 16

End Sub

TOP

        ÀR«ä¦Û¦b : ¸Ü¦h¤£¦p¸Ü¤Ö¡A¸Ü¤Ö¤£¦p¸Ü¦n¡C
ªð¦^¦Cªí ¤W¤@¥DÃD