Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to bypass cloudflare in headless chrome #847

Closed
M-Zubair10 opened this issue Oct 21, 2022 · 4 comments
Closed

Any way to bypass cloudflare in headless chrome #847

M-Zubair10 opened this issue Oct 21, 2022 · 4 comments

Comments

@M-Zubair10
Copy link

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
Copy link

mdmintz commented Oct 22, 2022

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
Copy link
Author

Thanks man you are a life saver!

@anovob
Copy link

anovob commented Jan 6, 2023

Chromedriver console open with Pyinstaller

@anovob
Copy link

anovob commented Jan 7, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants