Skip to content

More UC Mode updates #3088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/raw_cf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""SB Manager using UC Mode & PyAutoGUI for bypassing CAPTCHAs."""
from seleniumbase import SB

with SB(uc=True, test=True) as sb:
url = "https://www.cloudflare.com/login"
sb.uc_open_with_reconnect(url, 5)
sb.uc_gui_handle_captcha() # PyAutoGUI press Tab and Spacebar
sb.sleep(2.5)

with SB(uc=True, test=True) as sb:
url = "https://www.cloudflare.com/login"
sb.uc_open_with_reconnect(url, 5)
sb.uc_gui_click_captcha() # PyAutoGUI click. (Linux needs it)
sb.sleep(2.5)
4 changes: 2 additions & 2 deletions mkdocs_build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ MarkupSafe==2.1.5
Jinja2==3.1.4
click==8.1.7
ghp-import==2.1.0
watchdog==5.0.0
watchdog==5.0.2
cairocffi==1.7.1
pathspec==0.12.1
Babel==2.16.0
Expand All @@ -20,7 +20,7 @@ lxml==5.3.0
pyquery==2.0.1
readtime==3.0.0
mkdocs==1.6.1
mkdocs-material==9.5.33
mkdocs-material==9.5.34
mkdocs-exclude-search==0.6.6
mkdocs-simple-hooks==0.1.5
mkdocs-material-extensions==1.3.1
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.30.1"
__version__ = "4.30.2"
30 changes: 28 additions & 2 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,19 @@ def find_edgedriver_version_to_use(use_version, driver_version):
return use_version


def has_cf(text):
def has_captcha(text):
if (
"<title>403 Forbidden</title>" in text
or "Permission Denied</title>" in text
or 'id="challenge-error-text"' in text
or "<title>Just a moment..." in text
or 'action="/?__cf_chl_f_tk' in text
or 'id="challenge-widget-' in text
or 'src="chromedriver.js"' in text
or 'class="g-recaptcha"' in text
or 'content="Pixelscan"' in text
or 'id="challenge-form"' in text
or "/challenge-platform" in text
or "window._cf_chl_opt" in text
or "/recaptcha/api.js" in text
or "/turnstile/" in text
Expand All @@ -377,7 +379,7 @@ def uc_special_open_if_cf(
status_str.startswith("3")
or status_str.startswith("4")
or status_str.startswith("5")
or has_cf(req_get.text)
or has_captcha(req_get.text)
):
special = True
if status_str == "403" or status_str == "429":
Expand Down Expand Up @@ -763,6 +765,8 @@ def _on_a_cf_turnstile_page(driver):
source = driver.get_page_source()
if (
'data-callback="onCaptchaSuccess"' in source
or "/challenge-platform/scripts/" in source
or 'id="challenge-widget-' in source
or "cf-turnstile-" in source
):
return True
Expand Down Expand Up @@ -866,6 +870,13 @@ def _uc_gui_click_captcha(
and driver.is_element_present("div.spacer div")
):
frame = "div.spacer div"
elif (
driver.is_element_present('script[src*="challenges.c"]')
and driver.is_element_present(
'[data-testid*="challenge-"] div'
)
):
frame = '[data-testid*="challenge-"] div'
elif (
(
driver.is_element_present('[name*="cf-turnstile-"]')
Expand All @@ -883,6 +894,14 @@ def _uc_gui_click_captcha(
)
):
frame = "%s .cf-turnstile-wrapper" % frame
elif (
frame != "iframe"
and driver.is_element_present(
'%s [name*="cf-turnstile"]' % frame
)
and driver.is_element_present("%s div" % frame)
):
frame = "%s div" % frame
elif driver.is_element_present(".cf-turnstile-wrapper"):
frame = ".cf-turnstile-wrapper"
elif driver.is_element_present(
Expand Down Expand Up @@ -1102,6 +1121,13 @@ def _uc_gui_handle_captcha(
and driver.is_element_present("div.spacer div")
):
frame = "div.spacer div"
elif (
driver.is_element_present('script[src*="challenges.c"]')
and driver.is_element_present(
'[data-testid*="challenge-"] div'
)
):
frame = '[data-testid*="challenge-"] div'
elif (
(
driver.is_element_present('[name*="cf-turnstile-"]')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
'pdfminer.six==20221105;python_version<"3.8"',
'pdfminer.six==20240706;python_version>="3.8"',
'cryptography==39.0.2;python_version<"3.9"',
'cryptography==43.0.0;python_version>="3.9"',
'cryptography==43.0.1;python_version>="3.9"',
'cffi==1.15.1;python_version<"3.8"',
'cffi==1.17.0;python_version>="3.8"',
"pycparser==2.22",
Expand Down