Skip to content

Commit 66ea3f1

Browse files
committed
Update the docs
1 parent cc355f6 commit 66ea3f1

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

examples/cdp_mode/ReadMe/index.html

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<div data-md-component="skip">
8787

8888

89-
<a href="#cdp-mode-usage" class="md-skip">
89+
<a href="#youtube-tutorials-that-cover-cdp-mode" class="md-skip">
9090
Skip to content
9191
</a>
9292

@@ -950,6 +950,15 @@
950950
</label>
951951
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
952952

953+
<li class="md-nav__item">
954+
<a href="#youtube-tutorials-that-cover-cdp-mode" class="md-nav__link">
955+
<span class="md-ellipsis">
956+
🎞️ YouTube tutorials that cover CDP Mode
957+
</span>
958+
</a>
959+
960+
</li>
961+
953962
<li class="md-nav__item">
954963
<a href="#cdp-mode-usage" class="md-nav__link">
955964
<span class="md-ellipsis">
@@ -2877,6 +2886,15 @@
28772886
</label>
28782887
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
28792888

2889+
<li class="md-nav__item">
2890+
<a href="#youtube-tutorials-that-cover-cdp-mode" class="md-nav__link">
2891+
<span class="md-ellipsis">
2892+
🎞️ YouTube tutorials that cover CDP Mode
2893+
</span>
2894+
</a>
2895+
2896+
</li>
2897+
28802898
<li class="md-nav__item">
28812899
<a href="#cdp-mode-usage" class="md-nav__link">
28822900
<span class="md-ellipsis">
@@ -2962,11 +2980,14 @@ <h1>🐙 CDP Mode</h1>
29622980

29632981
<h2><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/img/logo6.png" title="SeleniumBase" width="32"></a> CDP Mode 🐙</h2>
29642982

2965-
<p>🐙 <b translate="no">SeleniumBase</b> <b translate="no">CDP Mode</b> is a stealth mode of SeleniumBase that uses the <a href="https://chromedevtools.github.io/devtools-protocol/" translate="no">Chrome Devtools Protocol</a> (via <a href="https://github.com/mdmintz/MyCDP" translate="no"><span translate="no">MyCDP</span></a>) to control the web browser. <b translate="no">CDP Mode</b> can be used either as a subset of <b><a href="../../../help_docs/uc_mode/" translate="no"><span translate="no">SeleniumBase UC Mode</span></a></b>, or via <b><a href="#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>🐙 <b translate="no">SeleniumBase</b> <b translate="no">CDP Mode</b> is a stealth mode that uses the <a href="https://chromedevtools.github.io/devtools-protocol/" translate="no">Chrome Devtools Protocol</a> (via <a href="https://github.com/mdmintz/MyCDP" translate="no"><span translate="no">MyCDP</span></a>) to control the web browser. <b translate="no">CDP Mode</b> can be used as a subset of <b><a href="../../../help_docs/uc_mode/" translate="no"><span translate="no">UC Mode</span></a></b>, or via <b><a href="#Pure_CDP_Mode" translate="no">Pure CDP Mode</a></b>, which has sync and async formats. From CDP Mode, you can make Playwright stealthy (<a translate="no" href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/playwright/ReadMe/">Stealthy Playwright Mode</a>).</p>
2984+
<p><img src="https://seleniumbase.github.io/other/sb_stealth.png" width="632" alt="High-Level Stealthy Architecture Overview" title="High-Level Stealthy Architecture Overview" /></p>
29662985
<hr />
2986+
<h3 id="youtube-tutorials-that-cover-cdp-mode">🎞️ YouTube tutorials that cover CDP Mode<a class="headerlink" href="#youtube-tutorials-that-cover-cdp-mode" title="Permanent link">&para;</a></h3>
29672987
<figure class="wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube"><div class="wp-block-embed__wrapper"><div class="epyt-video-wrapper fluid-width-video-wrapper" style="padding-top: 3px !important;"><iframe loading="lazy" id="_ytid_36718" data-origwidth="1200" data-origheight="675" src="https://www.youtube.com/embed/Mr90iQmNsKM?enablejsapi=1&amp;origin=https://seleniumbase.io&amp;autoplay=0&amp;cc_load_policy=0&amp;cc_lang_pref=&amp;iv_load_policy=1&amp;loop=0&amp;modestbranding=1&amp;rel=0&amp;fs=1&amp;playsinline=0&amp;autohide=2&amp;theme=dark&amp;color=red&amp;controls=1&amp;" class="__youtube_prefs__ no-lazyload" title="YouTube player" allow="autoplay; encrypted-media" allowfullscreen="" data-no-lazy="1" data-skipgform_ajax_framebjll=""></iframe></div></div></figure>
2968-
<p>(<b><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM">Watch the CDP Mode tutorial on YouTube! ▶️</a></b>)</p>
2988+
<p>(<b><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM">Watch "Undetectable Automation 4" on YouTube! ▶️</a></b>)</p>
29692989

2990+
<p>(See <code>examples/cdp_mode/</code> for up-to-date examples.)</p>
29702991
<hr />
29712992
<figure class="wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube"><div class="wp-block-embed__wrapper"><div class="epyt-video-wrapper fluid-width-video-wrapper" style="padding-top: 3px !important;"><iframe loading="lazy" id="_ytid_36718" data-origwidth="1200" data-origheight="675" src="https://www.youtube.com/embed/vt2zsdiNh3U?enablejsapi=1&amp;origin=https://seleniumbase.io&amp;autoplay=0&amp;cc_load_policy=0&amp;cc_lang_pref=&amp;iv_load_policy=1&amp;loop=0&amp;modestbranding=1&amp;rel=0&amp;fs=1&amp;playsinline=0&amp;autohide=2&amp;theme=dark&amp;color=red&amp;controls=1&amp;" class="__youtube_prefs__ no-lazyload" title="YouTube player" allow="autoplay; encrypted-media" allowfullscreen="" data-no-lazy="1" data-skipgform_ajax_framebjll=""></iframe></div></div></figure>
29722993
<p>(<b><a href="https://www.youtube.com/watch?v=vt2zsdiNh3U">Watch "Hacking websites with CDP" on YouTube! ▶️</a></b>)</p>
@@ -2976,17 +2997,15 @@ <h2><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://se
29762997
<p>(<b><a href="https://www.youtube.com/watch?v=gEZhTfaIxHQ">Watch "Web-Scraping with GitHub Actions" on YouTube! ▶️</a></b>)</p>
29772998

29782999
<hr />
2979-
<p>👤 <b translate="no">UC Mode</b> avoids bot-detection by first disconnecting WebDriver from the browser at strategic times, calling special <code><a href="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 <b translate="no">CDP Mode</b> comes in.)</p>
2980-
<p>🐙 <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>.)</p>
3000+
<p>👤 <b translate="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 <b translate="no">CDP Mode</b> comes in.)</p>
29813001
<p>🐙 <b translate="no">CDP Mode</b> includes multiple updates to the above, such as:</p>
29823002
<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>
29853004
<li>Backwards compatibility for existing UC Mode scripts.</li>
29863005
<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. <a href="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>
29903009
</ul>
29913010
<hr />
29923011
<h3 id="cdp-mode-usage">🐙 <b translate="no">CDP Mode</b> Usage<a class="headerlink" href="#cdp-mode-usage" title="Permanent link">&para;</a></h3>
@@ -3013,22 +3032,22 @@ <h3 id="cdp-mode-usage">🐙 <b translate="no">CDP Mode</b> Usage<a class="heade
30133032
<p><img src="https://seleniumbase.github.io/other/cf_sec.jpg" title="SeleniumBase" width="332"> <img src="https://seleniumbase.github.io/other/gitlab_bypass.png" title="SeleniumBase" width="288"></p>
30143033
<p>(If the CAPTCHA wasn't bypassed automatically when going to the URL, then <code>sb.solve_captcha()</code> gets the job done.)</p>
30153034
<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>:
3036+
(<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_planetmc.py">SeleniumBase/examples/cdp_mode/raw_planetmc.py</a>)</p>
30173037
<div class="highlight"><pre><span></span><code><span class="kn">from</span><span class="w"> </span><span class="nn">seleniumbase</span><span class="w"> </span><span class="kn">import</span> <span class="n">SB</span>
30183038

3019-
<span class="k">with</span> <span class="n">SB</span><span class="p">(</span><span class="n">uc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">test</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">as</span> <span class="n">sb</span><span class="p">:</span>
3039+
<span class="k">with</span> <span class="n">SB</span><span class="p">(</span><span class="n">uc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">test</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">guest</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">as</span> <span class="n">sb</span><span class="p">:</span>
30203040
<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;www.planetminecraft.com/account/sign_in/&quot;</span>
30213041
<span class="n">sb</span><span class="o">.</span><span class="n">activate_cdp_mode</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
30223042
<span class="n">sb</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
3023-
<span class="n">sb</span><span class="o">.</span><span class="n">cdp</span><span class="o">.</span><span class="n">gui_click_element</span><span class="p">(</span><span class="s2">&quot;#turnstile-widget div&quot;</span><span class="p">)</span>
3043+
<span class="n">sb</span><span class="o">.</span><span class="n">solve_captcha</span><span class="p">()</span>
30243044
<span class="n">sb</span><span class="o">.</span><span class="n">wait_for_element_absent</span><span class="p">(</span><span class="s2">&quot;input[disabled]&quot;</span><span class="p">)</span>
30253045
<span class="n">sb</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
30263046
</code></pre></div>
30273047
<p><img src="https://seleniumbase.github.io/other/planet_mc.png" title="SeleniumBase" width="480"></p>
3028-
<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:
3029-
Eg. <code>sb.cdp.gui_click_element("#turnstile-widget div")</code></p>
3030-
<p><img src="https://seleniumbase.github.io/other/above_shadow.png" title="SeleniumBase" width="480"></p>
3031-
<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 <a href="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>
30323051
<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>
30333052
<hr />
30343053
<h3 id="here-are-a-few-common-sbcdp-methods">🐙 Here are a few common <code>sb.cdp</code> methods<a class="headerlink" href="#here-are-a-few-common-sbcdp-methods" title="Permanent link">&para;</a></h3>
@@ -3052,7 +3071,7 @@ <h3 id="here-are-a-few-common-sbcdp-methods">🐙 Here are a few common <code>sb
30523071
<ul>
30533072
<li><strong><code>sb.disconnect()</code></strong></li>
30543073
</ul>
3055-
<p>While disconnected, if you accidentally call a WebDriver method, then <b translate="no">SeleniumBase</b> will attempt to use the <b translate="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 <b translate="no">CDP Mode</b> version. Not all WebDriver methods have a matching <b translate="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 <b translate="no">SeleniumBase</b> will attempt to use the <b translate="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 <b translate="no">CDP Mode</b> version. Not all WebDriver methods have a matching <b translate="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>
30563075
<p>To find out if WebDriver is connected or disconnected, call:</p>
30573076
<ul>
30583077
<li><strong><code>sb.is_connected()</code></strong></li>

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)