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: help_docs/uc_mode.md
+15-9Lines changed: 15 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,11 @@
21
21
22
22
----
23
23
24
-
👤 <btranslate="no">UC Mode</b> is based on [undetected-chromedriver](https://github.com/ultrafunkamsterdam/undetected-chromedriver), but includes multiple updates, fixes, and improvements, such as:
24
+
👤 <btranslate="no">UC Mode</b> is based on [undetected-chromedriver](https://github.com/ultrafunkamsterdam/undetected-chromedriver). <spantranslate="no">UC Mode</span> includes multiple updates, fixes, and improvements, such as:
25
25
26
-
* Automatically changing useragents to prevent detection.
27
-
* Automatically setting various chromium args as needed.
28
-
* Has special `uc_*()` methods.
26
+
* Automatically changing user-agents to prevent detection.
27
+
* Automatically setting various Chromium args as needed.
28
+
* Has special `uc_*()` methods for bypassing CAPTCHAs.
29
29
30
30
👤 Here's a simple example with the <b><codetranslate="no">Driver</code></b> manager:
31
31
@@ -129,6 +129,8 @@ with SB(uc=True, test=True, ad_block=True) as sb:
👤 <b>On Linux</b>, use `sb.uc_gui_click_captcha()` to handle CAPTCHAs (Cloudflare Turnstiles):
133
135
134
136
```python
@@ -150,6 +152,8 @@ with SB(uc=True, test=True) as sb:
150
152
151
153
The 2nd <codetranslate="no">print()</code> should output <codetranslate="no">Virtual Manager</code>, which means that the automation successfully passed the Turnstile.
152
154
155
+
(Note: <spantranslate="no">UC Mode</span> is detectable in Headless Mode, so don't combine those options. Instead, use <codetranslate="no">xvfb=True</code> / `--xvfb`on Linux for the special virtual display, which is enabled by default when not changing headed/headless settings.)
156
+
153
157
--------
154
158
155
159
👤 In <btranslate="no">UC Mode</b>, <codetranslate="no">driver.get(url)</code> has been modified from its original version: If anti-bot services are detected from a <codetranslate="no">requests.get(url)</code> call that's made before navigating to the website, then <codetranslate="no">driver.uc_open_with_reconnect(url)</code> will be used instead. To open a URL normally in <btranslate="no">UC Mode</b>, use <codetranslate="no">driver.default_get(url)</code>.
@@ -164,7 +168,7 @@ The 2nd <code translate="no">print()</code> should output <code translate="no">V
164
168
165
169
--------
166
170
167
-
👤 Here's an example where **`incognito=True` is needed for bypassing detection**:
171
+
👤 Here's an example where <b><codetranslate="no">incognito=True</code> is needed for bypassing detection</b>:
(Note that the <b><codetranslate="no">reconnect_time</code></b> is used to specify how long the driver should be disconnected from Chrome to prevent detection before reconnecting again.)
235
239
236
-
👤 Since <b><codetranslate="no">driver.get(url)</code></b> is slower in UC Mode for bypassing detection, use <b><codetranslate="no">driver.default_get(url)</code></b> for a standard page load instead:
240
+
👤 Since <b><codetranslate="no">driver.get(url)</code></b> is slower in <spantranslate="no">UC Mode</span> for bypassing detection, use <b><codetranslate="no">driver.default_get(url)</code></b> for a standard page load instead:
237
241
238
242
```python
239
243
driver.default_get(url) # Faster, but Selenium can be detected
👤 On Linux, you may need to use <codetranslate="no">uc_gui_click_captcha()</code> to successfully bypass a CAPTCHA. If there's more than one CAPTCHA on a website, then put the CSS Selector of an element that's above the CAPTCHA as the first arg to <codetranslate="no">uc_gui_click_captcha()</code>. This method uses <codetranslate="no">pyautogui</code>. In order for <codetranslate="no">pyautogui</code> to focus on the correct element, use <codetranslate="no">xvfb=True</code> / <codetranslate="no">--xvfb</code> to activate a special virtual display on Linux.
272
+
👤 <b>On Linux</b>, use <codetranslate="no">xvfb=True</code> / `--xvfb` to activate a special virtual display. This allows you to run a regular browser in an environment that has no GUI. This is important for two reasons: One: <spantranslate="no">UC Mode</span> is detectable in headless mode. Two: <codetranslate="no">pyautogui</code> doesn't work in headless mode. (Note that some methods such as <codetranslate="no">uc_gui_click_captcha()</code> require <codetranslate="no">pyautogui</code> for performing special actions.)
273
+
274
+
--------
269
275
270
276
👤 <codetranslate="no">uc_gui_click_captcha()</code> auto-detects the CAPTCHA type before trying to click it. This is a generic method for both CF Turnstile and Google reCAPTCHA. It will use the code from <codetranslate="no">uc_gui_click_cf()</code> and <codetranslate="no">uc_gui_click_rc()</code> as needed.
271
277
@@ -342,7 +348,7 @@ For example, if the <b translate="no">Chrome DevTools Console</b> variables aren
342
348
343
349
If you launch <btranslate="no">Chrome</b> using <b><codetranslate="no">chromedriver</code></b>, then there will be settings that make your browser look like a bot. (Instead, <btranslate="no">UC Mode</b> connects <b><codetranslate="no">chromedriver</code></b> to <btranslate="no">Chrome</b> after the browser is launched, which makes <btranslate="no">Chrome</b> look like a normal, human-controlled web browser.)
344
350
345
-
While <b><codetranslate="no">chromedriver</code></b> is connected to <btranslate="no">Chrome</b>, website services can detect it. Thankfully, raw <b><codetranslate="no">selenium</code></b> already includes <b><codetranslate="no">driver.service.stop()</code></b> for stopping the <b><codetranslate="no">chromedriver</code></b> service, <b><codetranslate="no">driver.service.start()</code></b> for starting the <b><codetranslate="no">chromedriver</code></b> service, and <b><codetranslate="no">driver.start_session(capabilities)</code></b> for reviving the active browser session with the given capabilities. (<btranslate="no"><code>SeleniumBase</code> UC Mode</b> methods automatically use those raw <b><codetranslate="no">selenium</code></b> methods as needed.)
351
+
While <b><codetranslate="no">chromedriver</code></b> is connected to <btranslate="no">Chrome</b>, website services can detect it. Thankfully, raw <b><codetranslate="no">selenium</code></b> already includes <b><codetranslate="no">driver.service.stop()</code></b> for stopping the <b><codetranslate="no">chromedriver</code></b> service, <b><codetranslate="no">driver.service.start()</code></b> for starting the <b><codetranslate="no">chromedriver</code></b> service, and <b><codetranslate="no">driver.start_session(capabilities)</code></b> for reviving the active browser session with the given capabilities. (<btranslate="no"><code>SeleniumBase</code> <spantranslate="no">UC Mode</span></b> methods automatically use those raw <b><codetranslate="no">selenium</code></b> methods as needed.)
346
352
347
353
Links to those <ahref="https://github.com/SeleniumHQ/selenium">raw <b>Selenium</b></a> method definitions have been provided for reference (but you don't need to call those methods directly):
0 commit comments