Skip to main content

Super Fast, Super Anti-Detect, and Super Intuitive Web Driver

Project description

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

not blocked

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")  # Use Google as the referer [Recommended]
    driver.get_via("https://www.example.com", referer="https://duckduckgo.com/")  # Use custom referer
    driver.get_via_this_page("https://www.example.com")  # Use current page as referer
    
  • For finding elements:

    from botasaurus.browser import Wait
    search_results = driver.select(".search-results", wait=Wait.SHORT)  # Wait for up to 4 seconds for the element to be present, return None if not found
    search_results = driver.wait_for_element(".search-results", wait=Wait.LONG)  # Wait for up to 8 seconds for the element to be present, raise exception if not found
    hello_mom = driver.get_element_with_exact_text("Hello Mom", wait=Wait.VERY_LONG)  # Wait for up to 16 seconds for an element having the exact text "Hello Mom"
    
  • Interact with elements:

    driver.type("input[name='username']", "john_doe")  # Type into an input field
    driver.click("button.submit")  # Clicks an element
    element = driver.select("button.submit")
    element.click()  # Click on an element
    
  • Retrieve element properties:

    header_text = driver.get_text("h1")  # Get text content
    error_message = driver.get_element_containing_text("Error: Invalid input")
    image_url = driver.select("img.logo").get_attribute("src")  # Get attribute value
    
  • Work with parent-child elements:

    parent_element = driver.select(".parent")
    child_element = parent_element.select(".child")
    child_element.click()  # Click child element
    
  • Execute JavaScript:

    result = driver.run_js("return document.title")
    text_content = element.run_js("(el) => el.textContent")
    
  • Working with iframes:

    driver.get("https://www.g2.com/products/github/reviews.html?page=5&product_id=github")
    iframe = driver.select_iframe("#turnstile-wrapper iframe")
    text_content = iframe.select("body label").text
    
  • Miscellaneous:

    form.type("input[name='password']", "secret_password")  # Type into a form field
    container.is_element_present(".button")  # Check element presence
    page_html = driver.page_html  # Current page HTML
    driver.select(".footer").scroll_into_view()  # Scroll element into view
    driver.close()  # Close the browser
    

Love It? Star It ⭐!

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.

Stargazers for @omkarcloud/botasaurus-driver

Made with ❤️ using Botasaurus Web Scraping Framework

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

botasaurus_driver-4.0.49.tar.gz (256.8 kB view details)

Uploaded Source

File details

Details for the file botasaurus_driver-4.0.49.tar.gz.

File metadata

  • Download URL: botasaurus_driver-4.0.49.tar.gz
  • Upload date:
  • Size: 256.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for botasaurus_driver-4.0.49.tar.gz
Algorithm Hash digest
SHA256 eb89b5ca6519ed19a85393815dc932c7384ccf4d90c0ced24f7ba556056e5d8f
MD5 958c8fd4228157f1df708bfc936419c5
BLAKE2b-256 396623f9bbad0bf26f951f8104faea37a7f0398861a84361e0151ed602da7596

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page