ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.42k stars 1.12k forks source link

Any way to bypass cloudflare in headless chrome #847

Closed M-Zubair10 closed 1 year ago

M-Zubair10 commented 1 year ago

Hi, I wanted to scrape websites in headless now, it works flawlessly in normal chrome but cloudflare is causing issue in headless Please give me any solution, even paid solution will be accepted, or new framework

mdmintz commented 1 year ago

You can use https://github.com/seleniumbase/SeleniumBase to do it. (It has a special undetected-chromedriver mode that works with headless mode.)

pip install -U seleniumbase

And then run the following with python:

from seleniumbase import Driver
from seleniumbase import page_actions

driver = Driver(headless=True, uc=True)
driver.get("https://nowsecure.nl")
page_actions.wait_for_text(driver, "OH YEAH, you passed!", "h1")
print(driver.find_element("css selector", "body").text)
screenshot_name = "now_secure_image.png"
driver.save_screenshot(screenshot_name)
print("\nScreenshot saved to: %s" % screenshot_name)
driver.quit()
M-Zubair10 commented 1 year ago

Thanks man you are a life saver!

anovob commented 1 year ago

Chromedriver console open with Pyinstaller

anovob commented 1 year ago
from seleniumbase import Driver
from seleniumbase import page_actions

driver = Driver(uc=True)
driver.get("https://nowsecure.nl")
page_actions.wait_for_text(driver, "OH YEAH, you passed!", "h1")
print(driver.find_element("css selector", "body").text)
screenshot_name = "now_secure_image.png"
driver.save_screenshot(screenshot_name)
print("\nScreenshot saved to: %s" % screenshot_name)
driver.quit()

Chromedriver console open with Pyinstaller