Update examples
This commit is contained in:
parent
c4d2d1ab10
commit
70be9b0dc6
|
@ -6,16 +6,21 @@
|
|||
|
||||
--------
|
||||
|
||||
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM"><img src="https://github.com/user-attachments/assets/91e7ff7b-d155-4ba9-b17b-b097825fcf42" title="SeleniumBase on YouTube" width="350" /></a>
|
||||
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM"><img src="https://github.com/user-attachments/assets/91e7ff7b-d155-4ba9-b17b-b097825fcf42" title="SeleniumBase on YouTube" width="320" /></a>
|
||||
<p>(<b><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM">Watch the CDP Mode tutorial on YouTube! ▶️</a></b>)</p>
|
||||
|
||||
--------
|
||||
|
||||
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=vt2zsdiNh3U"><img src="https://github.com/user-attachments/assets/82ab2715-727e-4d09-9314-b8905795dc43" title="SeleniumBase on YouTube" width="350" /></a>
|
||||
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=vt2zsdiNh3U"><img src="https://github.com/user-attachments/assets/82ab2715-727e-4d09-9314-b8905795dc43" title="SeleniumBase on YouTube" width="320" /></a>
|
||||
<p>(<b><a href="https://www.youtube.com/watch?v=vt2zsdiNh3U">Watch "Hacking websites with CDP" on YouTube! ▶️</a></b>)</p>
|
||||
|
||||
--------
|
||||
|
||||
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=gEZhTfaIxHQ"><img src="https://github.com/user-attachments/assets/656977e1-5d66-4d1c-9eec-0aaa41f6522f" title="SeleniumBase on YouTube" width="320" /></a>
|
||||
<p>(<b><a href="https://www.youtube.com/watch?v=gEZhTfaIxHQ">Watch "Web-Scraping with GitHub Actions" on YouTube! ▶️</a></b>)</p>
|
||||
|
||||
--------
|
||||
|
||||
👤 <b translate="no">UC Mode</b> avoids bot-detection by first disconnecting WebDriver from the browser at strategic times, calling special <code>PyAutoGUI</code> methods to bypass CAPTCHAs (as needed), and finally reconnecting the <code>driver</code> 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 <b translate="no">CDP Mode</b> comes in.)
|
||||
|
||||
🐙 <b translate="no">CDP Mode</b> is based on <a href="https://github.com/HyperionGray/python-chrome-devtools-protocol" translate="no">python-cdp</a>, <a href="https://github.com/HyperionGray/trio-chrome-devtools-protocol" translate="no">trio-cdp</a>, and <a href="https://github.com/ultrafunkamsterdam/nodriver" translate="no">nodriver</a>. <code>trio-cdp</code> is an early implementation of <code>python-cdp</code>, and <code>nodriver</code> is a modern implementation of <code>python-cdp</code>. (Refactored <code>Python-CDP</code> code is imported from <a href="https://github.com/mdmintz/MyCDP" translate="no">MyCDP</a>.)
|
||||
|
|
|
@ -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"]')
|
|
@ -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)
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue