diff --git a/examples/cdp_mode/ReadMe.md b/examples/cdp_mode/ReadMe.md index 970d4539..88e3d6f2 100644 --- a/examples/cdp_mode/ReadMe.md +++ b/examples/cdp_mode/ReadMe.md @@ -6,16 +6,21 @@ -------- - +

(Watch the CDP Mode tutorial on YouTube! ▶️)

-------- - +

(Watch "Hacking websites with CDP" on YouTube! ▶️)

-------- + +

(Watch "Web-Scraping with GitHub Actions" on YouTube! ▶️)

+ +-------- + 👤 UC Mode avoids bot-detection by first disconnecting WebDriver from the browser at strategic times, calling special PyAutoGUI methods to bypass CAPTCHAs (as needed), and finally reconnecting the driver afterwards so that WebDriver actions can be performed again. Although this approach works for bypassing simple CAPTCHAs, more flexibility is needed for bypassing bot-detection on websites with advanced protection. (That's where CDP Mode comes in.) 🐙 CDP Mode is based on python-cdp, trio-cdp, and nodriver. trio-cdp is an early implementation of python-cdp, and nodriver is a modern implementation of python-cdp. (Refactored Python-CDP code is imported from MyCDP.) diff --git a/examples/cdp_mode/raw_glassdoor.py b/examples/cdp_mode/raw_glassdoor.py new file mode 100644 index 00000000..5fc31491 --- /dev/null +++ b/examples/cdp_mode/raw_glassdoor.py @@ -0,0 +1,11 @@ +from seleniumbase import SB + +with SB(uc=True, test=True, ad_block=True) as sb: + url = "https://www.glassdoor.com/Reviews/index.htm" + sb.activate_cdp_mode(url) + sb.uc_gui_click_captcha() + sb.highlight('[data-test="global-nav-glassdoor-logo"]') + sb.highlight('[data-test="site-header-companies"]') + sb.highlight('[data-test="search-button"]') + sb.highlight('[data-test="sign-in-button"]') + sb.highlight('[data-test="company-search-autocomplete"]') diff --git a/examples/raw_invisible_captcha.py b/examples/raw_invisible_captcha.py new file mode 100644 index 00000000..54989667 --- /dev/null +++ b/examples/raw_invisible_captcha.py @@ -0,0 +1,9 @@ +from seleniumbase import SB + +with SB(uc=True, test=True, incognito=True) as sb: + url = "https://seleniumbase.io/apps/invisible_recaptcha" + sb.activate_cdp_mode(url) + sb.sleep(1) + sb.assert_element("img#captcha-success", timeout=3) + sb.set_messenger_theme(location="top_left") + sb.post_message("SeleniumBase wasn't detected", duration=3) diff --git a/examples/raw_recaptcha.py b/examples/raw_recaptcha.py index 51cfc164..8277f567 100644 --- a/examples/raw_recaptcha.py +++ b/examples/raw_recaptcha.py @@ -1,14 +1,5 @@ from seleniumbase import SB -with SB(uc=True, test=True, incognito=True) as sb: - url = "https://seleniumbase.io/apps/recaptcha" - sb.activate_cdp_mode(url) - sb.sleep(1) - sb.uc_gui_handle_captcha() # Try with TAB + SPACEBAR - sb.assert_element("img#captcha-success", timeout=3) - sb.set_messenger_theme(location="top_left") - sb.post_message("SeleniumBase wasn't detected", duration=3) - with SB(uc=True, test=True, incognito=True) as sb: url = "https://seleniumbase.io/apps/recaptcha" sb.activate_cdp_mode(url) diff --git a/examples/uc_cdp_events.py b/examples/uc_cdp_events.py index 6fcaf2c2..1e596a1f 100644 --- a/examples/uc_cdp_events.py +++ b/examples/uc_cdp_events.py @@ -1,6 +1,6 @@ from rich.pretty import pprint from seleniumbase import BaseCase -BaseCase.main(__name__, __file__, "--uc", "--uc-cdp", "-s") +BaseCase.main(__name__, __file__, "--uc", "--uc-cdp") class CDPTests(BaseCase): diff --git a/examples/verify_undetected.py b/examples/verify_undetected.py index e00ab35a..555c485d 100644 --- a/examples/verify_undetected.py +++ b/examples/verify_undetected.py @@ -2,7 +2,7 @@ Some sites use scripts to detect Selenium, and then block you. To evade detection, add --uc as a pytest command-line option.""" from seleniumbase import BaseCase -BaseCase.main(__name__, __file__, "--uc", "-s") +BaseCase.main(__name__, __file__, "--uc") class UndetectedTest(BaseCase):