From 9f727e1f463b19f1a9c712c487ae3fa5684c8b9f Mon Sep 17 00:00:00 2001 From: Leon Date: Sun, 22 Dec 2019 14:27:20 +0100 Subject: [PATCH] Update __init__.py --- undetected_chromedriver/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/undetected_chromedriver/__init__.py b/undetected_chromedriver/__init__.py index 4cfb8ad..a56ea4a 100644 --- a/undetected_chromedriver/__init__.py +++ b/undetected_chromedriver/__init__.py @@ -138,18 +138,17 @@ class ChromeDriverManager(object): installed = False selenium_patched = False + def __init__(self, executable_path=None, target_version=None, *args, **kwargs): self.executable_path = executable_path or "chromedriver.exe" self.platform = sys.platform self.target_version = target_version + def patch_selenium_webdriver(self_): """ - Patches existing webdriver path on OR if executable_path is None, will download - and patch a new webdriver binary for chrome (automatically finds latest release of main version) + Patches selenium package Chrome, ChromeOptions classes for current session - :param str executable_path: OPTIONAL path to existing chromedriver executable to patch - :param int version_int: OPTIONAL target chrome main version. default 79 :return: """ import selenium.webdriver.chrome.service @@ -161,6 +160,7 @@ class ChromeDriverManager(object): ) self_.__class__.selenium_patched = True + def install(self, patch_selenium=True): """ Initialize the patch @@ -185,6 +185,7 @@ class ChromeDriverManager(object): if patch_selenium: self.patch_selenium_webdriver() + def get_release_version_number(self): """ Gets the latest major version available, or the latest major version of self.target_version if set explicitly. @@ -198,6 +199,7 @@ class ChromeDriverManager(object): ) return urlopen(_DL_BASE + path).read().decode() + def fetch_chromedriver(self): """ Downloads ChromeDriver from source and unpacks the executable @@ -217,6 +219,7 @@ class ChromeDriverManager(object): os.remove(zip_name) return exe_name + def patch_binary(self): """ Patches the ChromeDriver binary