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
<p>🐙 <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">Chrome Devtools Protocol</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="../../../help_docs/uc_mode/" 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.</p>
2983
+
<p>🐙 <btranslate="no">SeleniumBase</b><btranslate="no">CDP Mode</b> is a stealth mode that uses the <ahref="https://chromedevtools.github.io/devtools-protocol/" translate="no">Chrome Devtools Protocol</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 as a subset of <b><ahref="../../../help_docs/uc_mode/" translate="no"><spantranslate="no">UC Mode</span></a></b>, or via <b><ahref="#Pure_CDP_Mode" translate="no">Pure CDP Mode</a></b>, which has sync and async formats. From CDP Mode, you can make Playwright stealthy (<atranslate="no" href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/playwright/ReadMe/">Stealthy Playwright Mode</a>).</p>
<p>(<b><ahref="https://www.youtube.com/watch?v=gEZhTfaIxHQ">Watch "Web-Scraping with GitHub Actions" on YouTube! ▶️</a></b>)</p>
2977
2998
2978
2999
<hr/>
2979
-
<p>👤 <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.)</p>
2980
-
<p>🐙 <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>.)</p>
3000
+
<p>👤 <btranslate="no">UC Mode</b>'s stealth is based on a modified chromedriver (<code>uc_driver</code>) that avoids bot-detection by disconnecting and reconnecting WebDriver from the browser at strategic times. Due to advancements in anti-bot technology, more stealth was needed to bypass advanced bot-detection. (That's where <btranslate="no">CDP Mode</b> comes in.)</p>
2981
3001
<p>🐙 <btranslate="no">CDP Mode</b> includes multiple updates to the above, such as:</p>
2982
3002
<ul>
2983
-
<li>Sync methods. (Using <code>async</code>/<code>await</code> is not necessary!)</li>
2984
-
<li>The ability to use WebDriver and CDP-Driver together.</li>
3003
+
<li>Using CDP directly, which is stealthier than WebDriver.</li>
2985
3004
<li>Backwards compatibility for existing UC Mode scripts.</li>
2986
3005
<li>More configuration options when launching browsers.</li>
2987
-
<li>More methods. (And bug-fixes for existing methods.)</li>
2988
-
<li><code>PyAutoGUI</code> integration for advanced stealth abilities.</li>
2989
-
<li>Faster response time for support. (Eg. <ahref="https://discord.gg/EdhQTn3EyE">Discord Chat</a>)</li>
3006
+
<li>The ability to use WebDriver and CDP calls together.</li>
3007
+
<li>Full access to call any advanced CDP library method.</li>
3008
+
<li>Can be used to make the Playwright library stealthy.</li>
<p>(If the CAPTCHA wasn't bypassed automatically when going to the URL, then <code>sb.solve_captcha()</code> gets the job done.)</p>
3015
3034
<hr/>
3016
-
<p>You can also use <code>PyAutoGUI</code> to click on elements with the mouse by calling <code>sb.cdp.gui_click_element(selector)</code>. Example:</p>
3035
+
<p>Here's another example that calls <code>sb.solve_captcha()</code>:
<p>When using <code>sb.cdp.gui_click_element(selector)</code> on CF Turnstiles, use the parent <code>selector</code> that appears <strong>above</strong> the <code>#shadow-root</code> element:
<p>In most cases, <code>sb.solve_captcha()</code> is good enough for CF Turnstiles without needing <code>sb.cdp.gui_click_element(selector)</code>. (See <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_planetmc.py">SeleniumBase/examples/cdp_mode/raw_planetmc.py</a>)</p>
3048
+
<p>In many cases, the CAPTCHA will be solved automatically without needing to call <code>solve_captcha()</code>.</p>
3049
+
<hr/>
3050
+
<p>You can also use <code>PyAutoGUI</code> to click on elements with the mouse by calling <code>sb.cdp.gui_click_element(selector)</code>.</p>
3032
3051
<p>ℹ️ Note that <code>PyAutoGUI</code> is an optional dependency. If calling a method that uses it when not already installed, then <code>SeleniumBase</code> installs <code>PyAutoGUI</code> at runtime.</p>
3033
3052
<hr/>
3034
3053
<h3id="here-are-a-few-common-sbcdp-methods">🐙 Here are a few common <code>sb.cdp</code> methods<aclass="headerlink" href="#here-are-a-few-common-sbcdp-methods" title="Permanent link">¶</a></h3>
@@ -3052,7 +3071,7 @@ <h3 id="here-are-a-few-common-sbcdp-methods">🐙 Here are a few common <code>sb
<p>While disconnected, if you accidentally call a WebDriver method, then <btranslate="no">SeleniumBase</b> will attempt to use the <btranslate="no">CDP Mode</b> version of that method (if available). For example, if you accidentally call <code>sb.click(selector)</code> instead of <code>sb.cdp.click(selector)</code>, then your WebDriver call will automatically be redirected to the <btranslate="no">CDP Mode</b> version. Not all WebDriver methods have a matching <btranslate="no">CDP Mode</b> method. In that scenario, calling a WebDriver method while disconnected could raise an error, or make WebDriver automatically reconnect first.</p>
3074
+
<p>While disconnected, if you accidentally call a WebDriver method, then <btranslate="no">SeleniumBase</b> will attempt to use the <btranslate="no">CDP Mode</b> version of that method (if available). For example, if you call <code>sb.click(selector)</code> instead of <code>sb.cdp.click(selector)</code>, then your WebDriver call will automatically be redirected to the <btranslate="no">CDP Mode</b> version. Not all WebDriver methods have a matching <btranslate="no">CDP Mode</b> method. In that scenario, calling a WebDriver method while disconnected could raise an error, or make WebDriver automatically reconnect first.</p>
3056
3075
<p>To find out if WebDriver is connected or disconnected, call:</p>
0 commit comments