Skip to content

Commit 7e60e3f

Browse files
committed
Refactor UC Mode
1 parent bf732fd commit 7e60e3f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def uc_special_open_if_cf(driver, url, proxy_string=None):
247247
or has_cf(req_get.text)
248248
):
249249
special = True
250-
if status_str == "403":
250+
if status_str == "403" or status_str == "429":
251251
time.sleep(0.06) # Forbidden / Blocked! (Wait first!)
252252
except Exception:
253253
pass
@@ -259,20 +259,20 @@ def uc_special_open_if_cf(driver, url, proxy_string=None):
259259
driver.switch_to.window(driver.window_handles[-1])
260260
time.sleep(0.02)
261261
else:
262-
driver.open(url) # The original one
262+
driver.default_get(url) # The original one
263263
else:
264-
driver.open(url) # The original one
264+
driver.default_get(url) # The original one
265265
return None
266266

267267

268268
def uc_open(driver, url):
269269
if (url.startswith("http:") or url.startswith("https:")):
270270
with driver:
271271
time.sleep(0.18)
272-
driver.open(url)
272+
driver.default_get(url)
273273
time.sleep(0.02)
274274
else:
275-
driver.open(url) # The original one
275+
driver.default_get(url) # The original one
276276
return None
277277

278278

@@ -285,7 +285,7 @@ def uc_open_with_tab(driver, url):
285285
driver.switch_to.window(driver.window_handles[-1])
286286
time.sleep(0.02)
287287
else:
288-
driver.open(url) # The original one
288+
driver.default_get(url) # The original one
289289
return None
290290

291291

@@ -297,7 +297,7 @@ def uc_open_with_reconnect(driver, url):
297297
driver.close()
298298
driver.switch_to.window(driver.window_handles[-1])
299299
else:
300-
driver.open(url) # The original one
300+
driver.default_get(url) # The original one
301301
return None
302302

303303

@@ -3538,7 +3538,7 @@ def get_local_driver(
35383538
service_args=["--disable-build-check"],
35393539
options=chrome_options,
35403540
)
3541-
driver.open = driver.get # Save copy of original
3541+
driver.default_get = driver.get # Save copy of original
35423542
if uc_activated:
35433543
driver.get = lambda url: uc_special_open_if_cf(
35443544
driver, url, proxy_string
@@ -3550,6 +3550,7 @@ def get_local_driver(
35503550
driver.uc_open_with_reconnect = (
35513551
lambda url: uc_open_with_reconnect(driver, url)
35523552
)
3553+
driver.open = driver.get # Shortcut
35533554
return driver
35543555
else: # Running headless on Linux (and not using --uc)
35553556
try:

0 commit comments

Comments
 (0)