Undetected selenium without chromedriver usage
Project description
Selenium-Driverless
- use selenium without chromedriver
- undetected by cloudfare and others
Feel free to test my code!
Getting Started
Dependencies
- Python >= 3.7
- Chrome-Browser installed
Installing
- Install Chrome-Browser
pip install selenium-driverless
Usage
with asyncio
from selenium_driverless import webdriver
import asyncio
async def main():
options = webdriver.ChromeOptions()
async with webdriver.Chrome(options=options) as driver:
await driver.get('http://nowsecure.nl#relax')
# wait for redirected page
await driver.wait_for_cdp(event="Page.loadEventFired", timeout=5)
title = await driver.title
url = await driver.current_url
source = await driver.page_source
print(title)
asyncio.run(main())
synchronous
asyncified, might be buggy
from selenium_driverless.sync import webdriver
options = webdriver.ChromeOptions()
with webdriver.Chrome(options=options) as driver:
driver.get('http://nowsecure.nl#relax')
# wait for redirected page
driver.wait_for_cdp(event="Page.loadEventFired", timeout=5)
title = driver.title
url = driver.current_url
source = driver.page_source
print(title)
use events
Note: synchronous might not work properly
from selenium_driverless import webdriver
import asyncio
global driver
async def on_request(params):
await driver.execute_cdp_cmd("Fetch.continueRequest", {"requestId": params['requestId']},
disconnect_connect=False)
print(params["request"]["url"])
async def main():
global driver
options = webdriver.ChromeOptions()
async with webdriver.Chrome(options=options) as driver:
await driver.get('http://nowsecure.nl#relax')
# enable Fetch, we don't want to disconnect after "Fetch.enable"
await driver.execute_cdp_cmd("Fetch.enable", disconnect_connect=False)
await driver.add_cdp_listener("Fetch.requestPaused", on_request)
await driver.wait_for_cdp(event="Page.loadEventFired", timeout=5)
await driver.remove_cdp_listener("Fetch.requestPaused", on_request)
await driver.execute_cdp_cmd("Fetch.disable")
print(await driver.title)
asyncio.run(main())
Help
Please feel free to open an issue or fork! note: please check the todo's below at first!
Todo
- implementations
-
WebDriverWait -
EC(expected-conditions) -
driver.switch_to.frameworkaround -
ActionChains
-
- protocoll
- add cdp event handler
- sync
- move sync to threaded for allowing event_handlers
- remove pycdp dependency -_-
Deprecated
Authors
License
Unless specified differently in a single file, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Disclaimer
I am not responsible what you use the code for!!! Also no warranty!
Acknowledgments
Inspiration, code snippets, etc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
selenium_driverless-1.3.tar.gz
(29.2 kB
view details)
File details
Details for the file selenium_driverless-1.3.tar.gz.
File metadata
- Download URL: selenium_driverless-1.3.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
647137bd7d9271065f8c0b91df5f5d4b18832ff12ff9c9d1a8141170e5ffeaec
|
|
| MD5 |
60fdcb0cab010aad9e70791c7d588d11
|
|
| BLAKE2b-256 |
846546b7d8cbda740f9b57a5478bd0a3467b26983bc61a6a964fc6dd56319396
|