Skip to main content

Undetected GeckoDriver v1.0.6

A Python package that integrates with Firefox Selenium to bypass anti-bot detection mechanisms, ideal for web scraping, automated testing, and browser automation without being marked as a bot.

PyPI version License: MIT Downloads Downloads Downloads

Preview

With undetected-geckodriver Without undetected-geckodriver
With undetected-geckodriver Without undetected-geckodriver

You can test it for yourself by going to this website

Overview

Undetected GeckoDriver is a powerful Python package designed to work seamlessly with the Selenium browser automation framework. Selenium allows you to control web browsers through code, making it an essential tool for web scraping, automated testing, and browser automation. However, when browsers are controlled by scripts (often referred to as "puppet browsers"), they typically set specific properties that can be detected by anti-bot services like Cloudflare. For instance, properties such as navigator.webdriver can be checked using JavaScript, which may restrict access to content on sites protected by such services.

To address this issue, Undetected GeckoDriver acts as an interface between your code and Selenium, helping you bypass bot detection mechanisms. When you create a new WebDriver instance using the Firefox() class from the Undetected GeckoDriver package (as opposed to using Selenium directly), the following processes occur:

  1. The original Firefox binary is located, copied, and patched to prevent it from modifying properties such as navigator.webdriver while using Selenium.
  2. A Selenium WebDriver instance is created that uses the patched Firefox binary.

This makes it possible to interact with websites without being detected as a bot, allowing you to scrape data, automate tasks, and perform other browser-based operations without triggering bot detection mechanisms.

Installation

You can install the package via pip:

pip install undetected-geckodriver

Or you can install it from source:

git clone https://github.com/bytexenon/undetected_geckodriver
cd undetected_geckodriver
pip install .

Usage

Since Undetected GeckoDriver acts as an interface for Selenium, you can use it the same way you would use Selenium.

You can integrate Undetected GeckoDriver into your existing Selenium code by simply replacing the selenium.webdriver.Firefox imports with undetected_geckodriver.Firefox.

Here are a couple of examples demonstrating how you can use this project:

  1. Creating a new undetected WebDriver instance and navigating to example.com:

    from undetected_geckodriver import Firefox
    
    driver = Firefox()
    driver.get("https://www.example.com")
    
  2. Searching for "Undetected Geckodriver 1337!" on Google:

    import time
    from undetected_geckodriver import Firefox
    from selenium.webdriver.common.by import By
    
    # Constants
    SEARCH_FOR = "Undetected Geckodriver 1337!"
    GOOGLE_URL = "https://www.google.com"
    
    # Initialize the undetected Firefox browser
    driver = Firefox()
    
    # Navigate to Google
    driver.get(GOOGLE_URL)
    
    # Locate the search box and perform the search
    search_box = driver.find_element(By.NAME, "q")
    search_box.send_keys(SEARCH_FOR)
    search_box.submit()
    
    # Wait for the page to load
    time.sleep(2)
    
    # Print the current URL after the search
    print("Current URL:", driver.current_url)
    
    # Wait for a while to observe the results
    time.sleep(15)
    
    # Ensure the browser is closed
    driver.quit() # Close the browser
    

For further information and advanced usage, you can take a look at the official Selenium documentation since Undetected GeckoDriver is built on top of Selenium.

Requirements

  • Firefox
  • Python >= 3.6
  • Selenium >= 4.10.0
  • Psutil >= 5.8.0

FAQ

The browser is still being detected as a bot. What should I do?

If your browser is still being detected as a bot while using Undetected GeckoDriver, it may be due to advanced bot detection mechanisms on the website. In such cases, please open an issue on the GitHub repository with the website URL and any relevant information. This will help in investigating and potentially adding support for it in future releases.

Why patch the Firefox binary?

When Firefox is controlled remotely by a script (such as when using Selenium), it sets certain properties that can be detected by anti-bot services as defined in the WebDriver specification. Selenium itself doesn't control these properties directly. By patching the Firefox binary, we can prevent it from modifying these properties, allowing us to interact with websites without being detected as a bot.

Why use Undetected GeckoDriver over undetected-chromedriver?

While undetected-chromedriver is a great tool for bypassing bot detection mechanisms, it only supports Chrome and Edge browsers. Undetected GeckoDriver fills this gap by providing similar functionality for Firefox browsers.

Roadmap

Completed:

  • Spoof navigator.webdriver property: Implement a method to spoof the navigator.webdriver property to prevent detection by services like Cloudflare. This helps in avoiding bot detection mechanisms.

In Progress:

  • Multi-platform support: Extend the compatibility of the tool to work seamlessly across different operating systems other than Linux (Windows, macOS). This includes ensuring all dependencies and configurations are platform-independent.

Planned:

  • Helper functions for passing CAPTCHAs and other security measures: Develop utility functions to automate the solving of CAPTCHAs and bypass other common security measures encountered during web scraping. (e.g. automatically passing Cloudflare's "I'm human" challenge)

  • Support for Selenium Wire: Integrate Selenium Wire to allow for more advanced network interactions, such as modifying requests and responses.

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request if you encounter any problems or have any suggestions, improvements, or new features you would like to see implemented.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Metadata

Release files for undetected-geckodriver 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for undetected-geckodriver 1.0.7
File Size Uploaded Provenance Actions
undetected_geckodriver-1.0.7.tar.gz 11.0 kB Without provenance Details for undetected_geckodriver-1.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for undetected-geckodriver 1.0.7
File Interpreter ABI Platform Actions
undetected_geckodriver-1.0.7-py3-none-any.whl Python 3 none any Details for undetected_geckodriver-1.0.7-py3-none-any.whl

Total release size: 20.2 kB

Release files / undetected_geckodriver-1.0.7.tar.gz

Download URL undetected_geckodriver-1.0.7.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4b68d63ecf227dc1ec9223a3eaff386a7aefee88934ee88f96e5bbb520512614
BLAKE2b-256 checksum
How to use checksums
d86608dc41358d129adb2cc8cd97a8704da4c5e239aa551e7597912d7b52829a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / undetected_geckodriver-1.0.7-py3-none-any.whl

Download URL undetected_geckodriver-1.0.7-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f082c733990701d4527cf6998e27916d306fa892051bb9fe4149680f6367d65
BLAKE2b-256 checksum
How to use checksums
fe247a03507674a1da8b8216df88fb46be492b79237761104c10c78f4fe8a9b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Security for undetected-geckodriver 1.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page