Closed schlabrendorff closed 3 years ago
Thanks for raising this issue.
With the code in your first example (the code which gives you the captcha page), can you try adding the disable_capture
option and see whether that makes a difference? e.g.
sw_options = {
'disable_capture': True
}
driver = webdriver.Chrome( # Optimized for bot detection
options=chrome_options,
seleniumwire_options=sw_options
)
This works (Google does not throw a captcha anymore), but as I need to access the response of a request made in the background for my use-case unfortunately not a solution.
Ok thanks. That suggests that the Google captcha is able to detect that the SSL handshake is taking place with Selenium Wire and not with the browser. When disable_capture
is True
Selenium Wire just passes the traffic straight through (no HTTPS decryption takes place) and as such the SSL handshake happens directly with the browser.
I'll have to investigate exactly how the SSL handshake is triggering the captcha. In the meantime in terms of workarounds, is the request that you want to access on a different domain than the Google captcha? If so, you could potentially exclude just the Google captcha request from Selenium Wire with the exclude_hosts
option:
sw_options = {
'exclude_hosts': ['google-captcha-host.com'] # Put the host of Google captcha here
}
driver = webdriver.Chrome( # Optimized for bot detection
options=chrome_options,
seleniumwire_options=sw_options
)
Actually thinking about it, the captcha is probably not being served separately - it's probably all originating from the same domain - so the above workaround is unlikely to be useful. I'll see if I can figure out why it's triggering in the first place.
Thank you for your answer! For my use-case I actually don't need to access Google. Because seleniumwire does not print anything whether it successfully uses undetected_chromedriver or not, I used Google as a test site, with. Is there another way to check whether undetected_chromedriver is used?
undetected_chromedriver will print out a log message when it starts up:
INFO:undetected_chromedriver:Selenium patched. Safe to import Chrome / ChromeOptions
INFO:undetected_chromedriver:starting undetected_chromedriver.Chrome((), {'options': <selenium.webdriver.chrome.options.Options object at 0x7fa070df3048>, 'seleniumwire_options': {}, 'executable_path': './chromedriver'})
You just need to ensure that you've activated logging at the very top of your script:
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('undetected_chromedriver').level = logging.INFO
from seleniumwire import webdriver
... code ...
Thank you! That is a good option!! May I propose mentioning it in the readme? i.e.
To ensure that seleniumwire
uses the patched chrome driver you can activate logging before importing from seleniumwire
:
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('undetected_chromedriver').level = logging.INFO
from seleniumwire import webdriver
... code ...
Yes good idea - will add that, thanks.
Hi!
I am trying to get selenium-wire to work with undetected-chromedriver as per the docs.
Conda Environment:
My Code:
This results in Google redirecting me to a captcha page.
While using undetected-chromedriver directly (without selenium wire) e.g. with this code.
works flawlessly. As well as this code:
Using the last code with seleniumwire instead of selenium, i.e.:
results in:
Does anybody have a hint what I am doing wrong or is this a bug?