- use selenium without chromedriver
- undetected by cloudfare, bet365 and others
- Python >= 3.7
- Chrome-Browser installed
- Install Chrome-Browser
pip install selenium-driverless
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')
await driver.implicitly_wait(0.5)
await driver.wait_for_cdp("Page.domContentEventFired", timeout=15)
title = await driver.title
url = await driver.current_url
source = await driver.page_source
print(title)
asyncio.run(main())
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')
driver.implicitly_wait(0.5)
driver.wait_for_cdp("Page.domContentEventFired", timeout=15)
title = driver.title
url = driver.current_url
source = driver.page_source
print(title)
from selenium_driverless import webdriver
options = webdriver.ChromeOptions()
options.debugger_address = "127.0.0.1:2005"
# specify if you don't want to run remote
# options.add_argument("--remote-debugging-port=2005")
async with webdriver.Chrome(options=options) as driver:
await driver.get('http://nowsecure.nl#relax', wait_load=True)
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())
from selenium_driverless.input.pointer import
await elem.scroll_to()
x, y = await elem.mid_location()
p = Pointer(driver=driver)
await p.click(x=x, y=y)
await p.doubble_click(x=x, y=y)
Please feel free to open an issue or fork! note: please check the todo's below at first!
- implementations
-
WebDriverWait
-
EC
(expected-conditions) -
driver.switch_to.frame
workaround -
ActionChains
-
execute_script
andexecute_async_script
- make serialization use
deep
- make serialization use
-
- protocoll
- add cdp event handler
- sync
- move sync to threaded for allowing event_handlers
- support multithreading with sync version
Unless specified differently in a single file, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
I am not responsible what you use the code for!!! Also no warranty!
Inspiration, code snippets, etc.