- ©«¤l
- 354
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 387
- ÂI¦W
- 0
- §@·~¨t²Î
- windows7
- ³nÅ骩¥»
- vba,vb,excel2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2017-1-8
- ³Ì«áµn¿ý
- 2024-8-2
|
¦^´_ 51# Scott090
¥Ñ©ó¦³¤H¤£ª¾¹Dn¥h¦w¸Ë¥D´¡¥ó ©Ò¥H¤]§â´¡¥ó¦w¸Ë¬yµ{¼g¶i¥h¤F
https://github.com/florentbr/SeleniumBasic/releases
SeleniumBasic v2.0.9.0.exe
²Ä¤@¦¸¦w¸Ë§¹¦¨«á,¥²¶·¦b¶}©l>°õ¦æselenium¤¤ªºstart chrome
µ¥«Ý¿ù»~¼u¥X¨Ã½T©w,±N¦Û°Ê¦w¸Ë.net framwork ¦w¸Ë§¹²¦«á«¶}¾÷
¦A°õ¦æ¥»µ{§Ç«h¥i¥H§ó·sª©¥»
Sub updataSelenium()
'¥Ñ©óselenium¦³¥i¯à·|¦w¸Ë¦bwindows¤U¨âӨ䤤¤@Ó¸ê®Æ§¨¤¤ ©Ò¥Hn¥ý§ä¥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 ¸ô®|
'Y¥¼¦w¸Ëselenium 2.0.9.0 ±N·|¸õÂà¨ìgithubºô¯¸ ½Ð¦Û¦æ¤U¸ü¦w¸Ë
If foler = "" Then
msg = "(½Ð©ç·Ó§ì¹Ï¥»µe±)" & vbCrLf
msg = msg & "§ä¤£¨ìselenium´¡¥ó¸ê®Æ§¨ »Ý¦Üºô¯¸" & vbCrLf & "https://github.com/florentbr/SeleniumBasic/releases"
msg = msg & vbCrLf & "¤U¸ü¦w¸Ë SeleniumBasic v2.0.9.0.exe" & vbCrLf & vbCrLf & "¬O§_ª½±µ«e©¹?"
msg = msg & vbCrLf & vbCrLf & "ª`·N«áÄò¨BÆJ:" & vbCrLf & "²Ä¤@¦¸¦w¸Ë§¹¦¨«á,¥²¶·¦b¶}©l>°õ¦æselenium¤¤ªºstart chrome" & vbCrLf
msg = msg & "µ¥«Ý¿ù»~¼u¥X¨Ã½T©w,±N¦Û°Ê¦w¸Ë.net framwork ¦w¸Ë§¹²¦«á«¶}¾÷" & vbCrLf & "¦A°õ¦æ¥»µ{§Ç«h¥i¥H§ó·sª©¥»"
x = MsgBox(msg, vbYesNo, "¥¼¦w¸Ë´¡¥ó")
If x = 6 Then
edgePath1 = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
edgePath2 = "C:\Program Files\Microsoft\Edge\Application\msedge.exe"
If Dir(edgePath1) <> "" Then edgePath = edgePath1
If Dir(edgePath2) <> "" Then edgePath = edgePath2
edgePath = """" & edgePath & """" & " https://github.com/florentbr/SeleniumBasic/releases"
Call Shell(edgePath, vbNormalFocus)
End If
Exit Sub
End If
'Àò¨ú·í«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 |
|