resolve conflicts
This commit is contained in:
commit
73f554f659
38
README.md
38
README.md
|
@ -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
|
* Works also on Brave Browser and many other Chromium based browsers, some tweaking
|
||||||
* Python 3.6++**
|
* 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!**
|
**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>
|
<br>
|
||||||
|
|
||||||
### The Version 2 way ###
|
### easy ###
|
||||||
Literally, this is all you have to do.
|
Literally, this is all you have to do.
|
||||||
Settings are included and your browser executable is found automagically.
|
Settings are included and your browser executable is found automagically.
|
||||||
This is also the snippet i recommend using in case you experience an issue.
|
This is also the snippet i recommend using in case you experience an issue.
|
||||||
```python
|
```python
|
||||||
import undetected_chromedriver.v2 as uc
|
import undetected_chromedriver.v2 as uc
|
||||||
driver = uc.Chrome()
|
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.
|
Literally, this is all you have to do.
|
||||||
If a specified folder does not exist, a NEW profile is created.
|
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.
|
Data dirs which are specified like this will not be autoremoved on exit.
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import undetected_chromedriver.v2 as uc
|
import undetected_chromedriver as uc
|
||||||
options = uc.ChromeOptions()
|
options = uc.ChromeOptions()
|
||||||
|
|
||||||
# setting profile
|
# setting profile
|
||||||
options.user_data_dir = "c:\\temp\\profile"
|
options.user_data_dir = "c:\\temp\\profile"
|
||||||
|
|
||||||
# another way to set profile is the below (which takes precedence if both variants are used
|
# use specific (older) version
|
||||||
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')
|
|
||||||
driver = uc.Chrome(options=options, version_main=94) # version_main allows to specify your chrome version instead of following chrome global 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.
|
Literally, this is all you have to do.
|
||||||
You can now listen and subscribe to the low level devtools-protocol.
|
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.
|
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
|
```python
|
||||||
|
|
||||||
import undetected_chromedriver.v2 as uc
|
import undetected_chromedriver as uc
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
|
||||||
driver = uc.Chrome(enable_cdp_events=True)
|
driver = uc.Chrome(enable_cdp_events=True)
|
||||||
|
|
|
@ -19,7 +19,11 @@ by UltrafunkAmsterdam (https://github.com/ultrafunkamsterdam)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
__version__ = "3.1.5r5"
|
__version__ = "3.1.5r5"
|
||||||
|
=======
|
||||||
|
__version__ = "3.1.6"
|
||||||
|
>>>>>>> 2742ff582d3d104ed8708b0ad7922b2166d65a52
|
||||||
|
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
|
@ -37,7 +41,9 @@ import selenium.webdriver.chrome.service
|
||||||
import selenium.webdriver.chrome.webdriver
|
import selenium.webdriver.chrome.webdriver
|
||||||
import selenium.webdriver.common.service
|
import selenium.webdriver.common.service
|
||||||
import selenium.webdriver.remote.webdriver
|
import selenium.webdriver.remote.webdriver
|
||||||
|
|
||||||
from selenium.webdriver.chrome.service import Service
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
import selenium.webdriver.remote.command
|
||||||
|
|
||||||
from .cdp import CDP
|
from .cdp import CDP
|
||||||
from .dprocess import start_detached
|
from .dprocess import start_detached
|
||||||
|
@ -118,9 +124,10 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
|
||||||
version_main=None,
|
version_main=None,
|
||||||
patcher_force_close=False,
|
patcher_force_close=False,
|
||||||
suppress_welcome=True,
|
suppress_welcome=True,
|
||||||
use_subprocess=False,
|
use_subprocess=True,
|
||||||
debug=False,
|
debug=False,
|
||||||
**kw,
|
no_sandbox=True,
|
||||||
|
**kw
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Creates a new instance of the chrome driver.
|
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.
|
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.
|
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
|
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
|
This fixes a LOT of issues, like multithreaded run, but mst importantly. shutting corectly after
|
||||||
program exits or using .quit()
|
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:
|
unfortunately, there is always an edge case in which one would like to write an single script with the only contents being:
|
||||||
--start script--
|
--start script--
|
||||||
|
@ -224,6 +232,10 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
|
||||||
in that case you can set this to `True`. The browser will start via subprocess, and will keep running most of times.
|
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. !
|
! 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
|
self.debug = debug
|
||||||
patcher = Patcher(
|
patcher = Patcher(
|
||||||
|
@ -352,6 +364,8 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
|
||||||
|
|
||||||
if suppress_welcome:
|
if suppress_welcome:
|
||||||
options.arguments.extend(["--no-default-browser-check", "--no-first-run"])
|
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:
|
if headless or options.headless:
|
||||||
options.headless = True
|
options.headless = True
|
||||||
options.add_argument("--window-size=1920,1080")
|
options.add_argument("--window-size=1920,1080")
|
||||||
|
@ -659,6 +673,13 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver):
|
||||||
if self.reactor and isinstance(self.reactor, Reactor):
|
if self.reactor and isinstance(self.reactor, Reactor):
|
||||||
self.reactor.handlers.clear()
|
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):
|
def tab_new(self, url: str):
|
||||||
"""
|
"""
|
||||||
this opens a url in a new tab.
|
this opens a url in a new tab.
|
||||||
|
|
Loading…
Reference in New Issue