Nodriver is a Python library for browser automation and web scraping, acting as the official successor to Undetected-Chromedriver. It communicates directly with browsers using the Chrome DevTools Protocol, eliminating the need for Selenium or WebDriver binaries, which significantly boosts performance and resistance against anti-bot systems. It is fully asynchronous and focuses on usability and quick prototyping. The current version is 0.48.1, and it seems to have a regular update cadence given the recent articles and version number.
pip install nodriverVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to launch a headless browser, navigate to a URL, retrieve the page title, and then close the page and browser instance. Nodriver operations are asynchronous and require `async`/`await`.
Rename your Python script file to something other than `nodriver.py` (e.g., `my_scraper.py`).
It is recommended to use `nodriver.loop().run_until_complete(main())` to ensure proper event loop handling and browser lifecycle management.
If encountering issues in headless mode, try running with `headless=False`. Also, consider adjusting browser arguments via `nodriver.Config` to better mimic human browsing patterns if stealth is critical.
Use a dedicated `user_data_dir` for `nodriver` (e.g., `Config(user_data_dir='path/to/nodriver_profile')`), increase the startup timeout for `nodriver.start(timeout=...)`, and ensure no orphaned Chrome processes are running before starting the script.
Ensure `opencv-python` is installed (`pip install opencv-python`) and avoid setting `expert=True` in `nodriver.start()` if you intend to use `cf_verify()`.
Rename your Python script file to anything other than `nodriver.py` (e.g., `main.py`, `scraper.py`).
Try killing any lingering Chrome processes, increase the startup timeout for `nodriver.start(timeout=...)`, or configure a dedicated user data directory for `nodriver` to prevent profile locking issues via `nodriver.Config(user_data_dir='path/to/new_profile')`.
Ensure that the element you are trying to interact with exists on the page when the command is called. Use `await page.wait_for_selector('selector')` or appropriate waits before interaction, and double-check your selectors or node IDs.Verify that Chrome/Chromium is installed and accessible. If you've provided a custom path, ensure it's correct. If not provided, ensure Chrome is installed in a default location `nodriver` can detect.
Ensure all `nodriver` calls are correctly `await`ed within `async` functions, and the main entry point is executed using `nodriver.loop().run_until_complete(main())`.