resolve conflicts

This commit is contained in:
UltrafunkAmsterdam 2022-11-20 21:44:17 +01:00
commit 73f554f659
2 changed files with 51 additions and 18 deletions

View File

@ -11,7 +11,23 @@ Automatically downloads the driver binary and patches it.
* Works also on Brave Browser and many other Chromium based browsers, some tweaking
* Python 3.6++**
### 3.1.0 ####
### 3.1.6 ###
### still passing strong ###
- use_subprocess now defaults to True. too many people don't understand multiprocessing and __name__ == '__main__, and after testing, it seems not to make a difference anymore in chrome 104+
- added no_sandbox, which defaults to True, and this without the annoying "you are using unsecure command line ..." bar.
- update [Docker image](https://hub.docker.com/r/ultrafunk/undetected-chromedriver).
you can now vnc or rdp into your container to see the actual browser window
[![demo](https://i.imgur.com/51Ang6R.gif)](https://i.imgur.com/W7vriN9.mp4)
- of course, "regular" mode works as well
[![demo](https://i.imgur.com/2qSNyuK.gif)](https://i.imgur.com/2qSNyuK.mp4)
### 3.1.0 ###
**this version `might` break your code, test before update!**
@ -91,42 +107,38 @@ To prevent unnecessary hair-pulling and issue-raising, please mind the **[import
<br>
### The Version 2 way ###
### easy ###
Literally, this is all you have to do.
Settings are included and your browser executable is found automagically.
This is also the snippet i recommend using in case you experience an issue.
```python
import undetected_chromedriver.v2 as uc
driver = uc.Chrome()
driver.get('https://nowsecure.nl') # known url using cloudflare's "under attack mode"
driver.get('https://nowsecure.nl') # my own test test site with max anti-bot protection
```
### The Version 2 more advanced way, including setting profie folder ###
### more advanced way, including setting profie folder ###
Literally, this is all you have to do.
If a specified folder does not exist, a NEW profile is created.
Data dirs which are specified like this will not be autoremoved on exit.
```python
import undetected_chromedriver.v2 as uc
import undetected_chromedriver as uc
options = uc.ChromeOptions()
# setting profile
options.user_data_dir = "c:\\temp\\profile"
# another way to set profile is the below (which takes precedence if both variants are used
options.add_argument('--user-data-dir=c:\\temp\\profile2')
# just some options passing in to skip annoying popups
options.add_argument('--no-first-run --no-service-autorun --password-store=basic')
# use specific (older) version
driver = uc.Chrome(options=options, version_main=94) # version_main allows to specify your chrome version instead of following chrome global version
driver.get('https://nowsecure.nl') # known url using cloudflare's "under attack mode"
driver.get('https://nowsecure.nl') # my own test test site with max anti-bot protection
```
### The Version 2 expert mode, including Devtool/Wire events! ###
### expert mode, including Devtool/Wire events ###
Literally, this is all you have to do.
You can now listen and subscribe to the low level devtools-protocol.
I just recently found out that is also on planning for future release of the official chromedriver.
@ -135,7 +147,7 @@ However i implemented my own for now. Since i needed it myself for investigation
```python
import undetected_chromedriver.v2 as uc
import undetected_chromedriver as uc
from pprint import pformat
driver = uc.Chrome(enable_cdp_events=True)

View File

@ -19,7 +19,11 @@ by UltrafunkAmsterdam (https://github.com/ultrafunkamsterdam)
"""
<<<<<<< HEAD
__version__ = "3.1.5r5"
=======
__version__ = "3.1.6"
>>>>>>> 2742ff582d3d104ed8708b0ad7922b2166d65a52
import inspect
@ -37,7 +41,9 @@ import selenium.webdriver.chrome.service
import selenium.webdriver.chrome.webdriver
import selenium.webdriver.common.service
import selenium.webdriver.remote.webdriver
from selenium.webdriver.chrome.service import Service
import selenium.webdriver.remote.command
from .cdp import CDP
from .dprocess import start_detached
@ -118,9 +124,10 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
version_main=None,
patcher_force_close=False,
suppress_welcome=True,
use_subprocess=False,
use_subprocess=True,
debug=False,
**kw,
no_sandbox=True,
**kw
):
"""
Creates a new instance of the chrome driver.
@ -207,11 +214,12 @@ 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,
use_subprocess: bool, optional , default: True,
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()
you should be knowing what you're doing, and know how python works.
unfortunately, there is always an edge case in which one would like to write an single script with the only contents being:
--start script--
@ -223,7 +231,11 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
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. !
no_sandbox: bool, optional, default=True
uses the --no-sandbox option, and additionally does suppress the "unsecure option" status bar
this option has a default of True since many people seem to run this as root (....) , and chrome does not start
when running as root without using --no-sandbox flag.
"""
self.debug = debug
patcher = Patcher(
@ -352,6 +364,8 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
if suppress_welcome:
options.arguments.extend(["--no-default-browser-check", "--no-first-run"])
if no_sandbox:
options.arguments.extend(["--no-sandbox", "--test-type"])
if headless or options.headless:
options.headless = True
options.add_argument("--window-size=1920,1080")
@ -658,7 +672,14 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
def clear_cdp_listeners(self):
if self.reactor and isinstance(self.reactor, Reactor):
self.reactor.handlers.clear()
def window_new(self):
self.execute(
selenium.webdriver.remote.command.Command.NEW_WINDOW,
{"type": "window"}
)
def tab_new(self, url: str):
"""
this opens a url in a new tab.