seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.46k stars 910 forks source link

Detailed Explanation and Usage of Website Connection Options and Parameters #2896

Closed PankajSavaliya closed 5 days ago

PankajSavaliya commented 5 days ago

Can you please explain these options in detail and when they should be used? There are many options available to load a website, connect, and disconnect, but why are these options available? I would also like to understand reconnect_time, timeout, and each feature so I can use them precisely.

I'm using this SB with multi-threading as per your document with UC so please give me the proper document for that way.

driver = Driver(uc=True, agent=generate_random_mobile_user_agent(False), )

  1. driver.uc_open(url)

  2. driver.uc_open_with_tab(url)

  3. driver.uc_open_with_reconnect(url, reconnect_time=None)

  4. driver.uc_open_with_disconnect(url, timeout=None)

  5. driver.reconnect(timeout)

  6. driver.disconnect()

  7. driver.connect()

mdmintz commented 5 days ago

The UC Mode docs are here: SeleniumBase/help_docs/uc_mode.md

And those methods are described in detail in the UC Mode video tutorials:


(Watch the 1st UC Mode tutorial on YouTube! ▶️)

----

(Watch the 2nd UC Mode tutorial on YouTube! ▶️)

---- Disconnecting the driver from Chrome makes Selenium less detectable during that time. ```python # "driver"-specific methods added (or modified) by SeleniumBase for UC Mode: driver.get(url) # If UC Mode and site detects bots, then uc_open_with_tab(url) driver.uc_open(url) # (Open in same tab with default reconnect_time) driver.uc_open_with_tab(url) # (New tab with default reconnect_time) driver.uc_open_with_reconnect(url, reconnect_time=None) # (New tab) driver.uc_open_with_disconnect(url, timeout=None) # New tab + sleep() driver.reconnect(timeout) # disconnect() + sleep(timeout) + connect() driver.disconnect() # Stops the webdriver service to prevent detection driver.connect() # Starts the webdriver service to allow actions again driver.uc_click(selector) # A stealthy click for evading bot-detection driver.uc_gui_press_key(key) # Use PyAutoGUI to press the keyboard key driver.uc_gui_press_keys(keys) # Use PyAutoGUI to press a list of keys driver.uc_gui_write(text) # Similar to uc_gui_press_keys(), but faster driver.uc_gui_handle_cf(frame="iframe") # PyAutoGUI click CF Turnstile ```
PankajSavaliya commented 5 days ago

@mdmintz in which these methods should be used? (Connect, Reconnect, and Disconnect) and when for undetection?

PankajSavaliya commented 4 days ago

@mdmintz in which these methods should be used? (Connect, Reconnect, and Disconnect) and when for undetection?

@mdmintz can you please explain when these methods should be called and which case? like click, and scroll.