From 3bf4cdf7a9c51078bccd4dd762da99f550b42035 Mon Sep 17 00:00:00 2001 From: Leon Date: Fri, 24 Dec 2021 15:31:51 +0100 Subject: [PATCH] 3.1.2 - some 'bug' fixes --- setup.py | 8 +++++--- undetected_chromedriver/__init__.py | 27 +++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 3576b98..239d588 100644 --- a/setup.py +++ b/setup.py @@ -46,10 +46,11 @@ setup( description="""\ selenium.webdriver.Chrome replacement wiht compatiblity for Brave, and other Chromium baed browsers. not triggered by CloudFlare/Imperva/hCaptcha and such. - NOTE: results may vary due to many factors. No guarantees are given, except for ongoing efforts in understanding detection algorithms. """, - long_description=open(os.path.join(dirname, "README.md"),encoding="utf-8").read(), + + long_description=open(os.path.join(dirname, "README.md"), encoding="utf-8").read(), + long_description_content_type="text/markdown", classifiers=[ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", @@ -57,6 +58,7 @@ setup( "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.10" + "Programming Language :: Python :: 3.11", ], ) diff --git a/undetected_chromedriver/__init__.py b/undetected_chromedriver/__init__.py index 9d41796..d89ab39 100644 --- a/undetected_chromedriver/__init__.py +++ b/undetected_chromedriver/__init__.py @@ -113,7 +113,7 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver): version_main=None, patcher_force_close=False, suppress_welcome=True, - detached_process=True, + no_subprocess=True, debug=False, **kw ): @@ -185,6 +185,23 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver): now, in case you are nag-fetishist, or a diagnostics data feeder to google, you can set this to False. Note: if you don't handle the nag screen in time, the browser loses it's connection and throws an Exception. + use_subprocess: bool, optional , default: False, + + False (the default) makes sure Chrome will get it's own process (so no subprocess of chromedriver.exe or python + This fixes a LOT of issues, like multithreaded run, but mst importantly. shutting corectly after + program exits or using .quit() + + unfortunately, there is always an edge case in which one would like to write an single script with the only contents being: + --start script-- + import undetected_chromedriver as uc + d = uc.Chrome() + d.get('https://somesite/') + ---end script -- + + and will be greeted with an error, since the program exists before chrome has a change to launch. + in that case you can set this to `True`. The browser will start via subprocess, and will keep running most of times. + ! setting it to True comes with NO support when being detected. ! + """ self.debug = debug patcher = Patcher( @@ -339,7 +356,9 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver): if not desired_capabilities: desired_capabilities = options.to_capabilities() - if not detached_process: + if not use_subprocess: + self.browser_pid = start_detached(options.binary_location, *options.arguments) + else: browser = subprocess.Popen( [options.binary_location, *options.arguments], stdin=subprocess.PIPE, @@ -348,8 +367,8 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver): close_fds=IS_POSIX, ) self.browser_pid = browser.pid - else: - self.browser_pid = start_detached(options.binary_location, *options.arguments) + + super(Chrome, self).__init__( executable_path=patcher.executable_path,