You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hide console interface with package using pyinstaller.
Necessary!!! selenium==4.5.0 , other version not work.
Comes with the following code.
fromseleniumimportwebdriverfromselenium.webdriver.chrome.optionsimportOptionsfromselenium.webdriver.chrome.serviceimportServiceasChromeService# Similar thing for firefox also!fromsubprocessimportCREATE_NO_WINDOW# This flag will only be available in windowschrome_options=Options()
chrome_options.add_argument('--headless')
chrome_service=ChromeService('chromedriver')
chrome_service.creationflags=CREATE_NO_WINDOWdriver=webdriver.Chrome(service=chrome_service, options=chrome_options)
Fix Chrome v115 with chromedriver_autoinstaller
Chrome v115.0.5790.110
chromedriver_autoinstaller == 0.6.2
locate to source utils.py
Point 1
defget_matched_chromedriver_version(chrome_version, no_ssl=False):
# Newer versions of chrome use the CfT publishing systemifchrome_version>="115":
version_url="googlechromelabs.github.io/chrome-for-testing/known-good-versions.json"version_url="http://"+version_urlifno_sslelse"https://"+version_urlgood_version_list=json.load(urllib.request.urlopen(version_url))
compare_version=chrome_version.rsplit('.', 1)[0]
forgood_versioningood_version_list["versions"]:
# if good_version["version"] == chrome_version:# return chrome_versionifgood_version["version"].startswith(compare_version):
returngood_version["version"]
# check old versions of chrome using the old systemelse:
version_url="chromedriver.storage.googleapis.com"version_url="http://"+version_urlifno_sslelse"https://"+version_urldoc=urllib.request.urlopen(version_url).read()
root=elemTree.fromstring(doc)
forkinroot.iter("{http://doc.s3.amazonaws.com/2006-03-01}Key"):
ifk.text.find(get_major_version(chrome_version) +".") ==0:
returnk.text.split("/")[0]
return
Point 2
defget_chrome_version():
ifplatform=="linux":
elifplatform=="mac":
elifplatform=="win":
# check both of Program Files and Program Files (x86).# if the version isn't found on both of them, version is an empty string.# dirs = [f.name for f in os.scandir("C:\\Program Files\\Google\\Chrome\\Application") if f.is_dir() and re.match("^[0-9.]+$", f.name)]# if dirs:# version = max(dirs)# else:# dirs = [f.name for f in os.scandir("C:\\Program Files (x86)\\Google\\Chrome\\Application") if f.is_dir() and re.match("^[0-9.]+$", f.name)]# version = max(dirs) if dirs else ''chrome_path="C:\\Program Files\\Google\\Chrome\\Application"ifnotos.path.exists(chrome_path):
chrome_path="C:\\Program Files (x86)\\Google\\Chrome\\Application"try:
dirs= [f.nameforfinos.scandir(chrome_path) iff.is_dir() andre.match("^[0-9.]+$", f.name)]
version=max(dirs) ifdirselse''exceptFileNotFoundError:
version=''else:
returnreturnversion
Could do better
Minimal exception handling.
Multi-threading/multi-process let chrome tabs parallel processing.