Botasaurus Driver
Botasaurus Driver is a powerful Driver Automation Python library that offers the following benefits:
- It is really humane; it looks and works exactly like a real browser, allowing it to access any website.
- Compared to Selenium and Playwright, it is super fast to launch and use.
- The API is designed by and for web scrapers, and you will love it.
Installation
pip install botasaurus-driver
Bypassing Bot Detection: Code Example
from botasaurus_driver import Driver
driver = Driver()
driver.google_get("https://www.g2.com/products/github/reviews.html?page=5&product_id=github", bypass_cloudflare=True)
driver.prompt()
heading = driver.get_text('.product-head__title [itemprop="name"]')
print(heading)
Result

API
Botasaurus Driver provides several handy methods for web automation tasks such as:
-
Navigate to URLs:
driver.get("https://www.example.com")
driver.google_get("https://www.example.com")
driver.get_via("https://www.example.com", referer="https://duckduckgo.com/")
driver.get_via_this_page("https://www.example.com")
-
For finding elements:
from botasaurus.browser import Wait
search_results = driver.select(".search-results", wait=Wait.SHORT)
search_results = driver.wait_for_element(".search-results", wait=Wait.LONG)
hello_mom = driver.get_element_with_exact_text("Hello Mom", wait=Wait.VERY_LONG)
-
Interact with elements:
driver.type("input[name='username']", "john_doe")
driver.click("button.submit")
element = driver.select("button.submit")
element.click()
-
Retrieve element properties:
header_text = driver.get_text("h1")
error_message = driver.get_element_containing_text("Error: Invalid input")
image_url = driver.select("img.logo").get_attribute("src")
-
Work with parent-child elements:
parent_element = driver.select(".parent")
child_element = parent_element.select(".child")
child_element.click()
-
Execute JavaScript:
result = driver.run_js("return document.title")
text_content = element.run_js("(el) => el.textContent")
-
Working with iframes:
driver.get("https://www.freecodecamp.org/news/using-entity-framework-core-with-mongodb/")
iframe = driver.get_iframe_by_link("www.youtube.com/embed")
freecodecamp_youtube_subscribers_count = iframe.select(".ytp-title-expanded-subtitle").text
-
Miscellaneous:
form.type("input[name='password']", "secret_password")
container.is_element_present(".button")
page_html = driver.page_html
driver.select(".footer").scroll_into_view()
driver.close()
Become one of our amazing stargazers by giving us a star ⭐ on GitHub!
It's just one click, but it means the world to me.
