You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,17 +66,19 @@
66
66
67
67
--------
68
68
69
-
<palign="left">📗 Here's a test script that performs a Google Search using SeleniumBase UC Mode:<br /><ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_google.py">SeleniumBase/examples/raw_google.py</a> (Results are saved as PDF, HTML, and PNG)</p>
69
+
<palign="left">📗 This script performs a Google Search using SeleniumBase UC Mode + CDP Mode:<br /><ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_google.py">SeleniumBase/examples/raw_google.py</a> (Results are saved as PDF, HTML, and PNG)</p>
🐙 <btranslate="no">SeleniumBase</b> <btranslate="no">CDP Mode</b> (<ahref="https://chromedevtools.github.io/devtools-protocol/"translate="no"><spantranslate="no">Chrome Devtools Protocol</span></a> Mode) is a special mode inside of <b><ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/uc_mode.md"translate="no"><spantranslate="no">SeleniumBase UC Mode</span></a></b> that lets bots appear human while controlling the browser with <btranslate="no">CDP</b> (via <ahref="https://github.com/mdmintz/MyCDP"translate="no"><spantranslate="no">MyCDP</span></a>). Although regular <btranslate="no">UC Mode</b> can't perform <spantranslate="no">WebDriver</span> actions while the <code>driver</code> is disconnected from the browser, <btranslate="no">CDP</b> can. <btranslate="no">CDP Mode</b> can also be used independently of WebDriver via <b><ahref="#Pure_CDP_Mode"translate="no">Pure CDP Mode</a></b> (<code>sb_cdp</code>).
5
+
🐙 <btranslate="no">SeleniumBase</b> <btranslate="no">CDP Mode</b> is a stealth mode of SeleniumBase that uses the <ahref="https://chromedevtools.github.io/devtools-protocol/"translate="no"><spantranslate="no">Chrome Devtools Protocol</span></a> (via <ahref="https://github.com/mdmintz/MyCDP"translate="no"><spantranslate="no">MyCDP</span></a>) to control the web browser. <btranslate="no">CDP Mode</b> can be used either as a subset of <b><ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/uc_mode.md"translate="no"><spantranslate="no">SeleniumBase UC Mode</span></a></b>, or via <b><ahref="#Pure_CDP_Mode"translate="no">Pure CDP Mode</a></b> (<code>sb_cdp</code>), which doesn't use WebDriver at all, and has a slightly different setup.
6
6
7
7
--------
8
8
@@ -21,7 +21,7 @@
21
21
22
22
--------
23
23
24
-
👤 <btranslate="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 <btranslate="no">CDP Mode</b> comes in.)
24
+
👤 <btranslate="no">UC Mode</b> avoids bot-detection by first disconnecting WebDriver from the browser at strategic times, calling special <code><ahref="https://github.com/asweigart/pyautogui">PyAutoGUI</a></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 <btranslate="no">CDP Mode</b> comes in.)
25
25
26
26
🐙 <btranslate="no">CDP Mode</b> is based on <ahref="https://github.com/HyperionGray/python-chrome-devtools-protocol"translate="no">python-cdp</a>, <ahref="https://github.com/HyperionGray/trio-chrome-devtools-protocol"translate="no">trio-cdp</a>, and <ahref="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 <ahref="https://github.com/mdmintz/MyCDP"translate="no">MyCDP</a>.)
(If the CAPTCHA wasn't bypassed automatically when going to the URL, then `sb.uc_gui_click_captcha()` gets the job done with a mouse click from [PyAutoGUI](https://github.com/asweigart/pyautogui).)
63
-
64
-
ℹ️ Note that `PyAutoGUI` is an optional dependency. If calling a method that uses it when not already installed, then `SeleniumBase` installs `PyAutoGUI` at run-time.
62
+
(If the CAPTCHA wasn't bypassed automatically when going to the URL, then `sb.solve_captcha()` gets the job done.)
65
63
66
64
--------
67
65
68
-
You can also use `sb.cdp.gui_click_element(selector)`to click on elements using `PyAutoGUI`. (This is useful when clicking inside `#shadow-root`.) Example:
66
+
`sb.cdp.gui_click_element(selector)`lets you click on elements using `PyAutoGUI`. Example:
In most cases, `sb.uc_gui_click_captcha()` is good enough for CF Turnstiles without needing `sb.cdp.gui_click_element(selector)`. (See [SeleniumBase/examples/cdp_mode/raw_planetmc.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_planetmc.py))
87
+
In most cases, `sb.solve_captcha()` is good enough for CF Turnstiles without needing `sb.cdp.gui_click_element(selector)`. (See [SeleniumBase/examples/cdp_mode/raw_planetmc.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_planetmc.py))
88
+
89
+
ℹ️ Note that `PyAutoGUI` is an optional dependency. If calling a method that uses it when not already installed, then `SeleniumBase` installs `PyAutoGUI` at run-time.
90
90
91
91
--------
92
92
93
93
### 🐙 Here are a few common `sb.cdp` methods:
94
94
95
95
*`sb.cdp.click(selector)` (Uses the CDP API to click)
96
96
*`sb.cdp.click_if_visible(selector)` (Click if visible)
97
+
*`sb.cdp.solve_captcha()` (Uses CDP to click a CAPTCHA)
0 commit comments