Z
Z
zasara2022-03-03 17:44:36
Python
zasara, 2022-03-03 17:44:36

How to bypass cloudflare bot protection?

I'm trying to access the site, but the site is protected from cloudflare bots
Here is the original code, the site gives an error
Checking your browser before accessing somesite
​ This process is automatic. Your browser will redirect to your requested content shortly.
Please allow up to 5 seconds…

from selenium import webdriver

browser = webdriver.Chrome(executable_path='/Users/ivanburylov/PycharmProjects/scraper/chromedriver')
url = 'https://somesite'
browser.get(url)
time.sleep(15)
browser.close()
browser.quit()


Tried via cfscrape library ( https://pypi.org/project/cfscrape/ ) but didn't work
Found undetected_chromedriver.v2 library ( https://github.com/ultrafunkamsterdam/undetected-c... )
Installed and uploaded to folder chromedriver, but when you run the code, the file is deleted and writes an error:
shutil.rmtree(self.user_data_dir, ignore_errors=False)
AttributeError: 'Chrome' object has no attribute 'user_data_dir'


Here is the code:
import undetected_chromedriver.v2 as uc

driver = uc.Chrome(executable_path='/Users/ivanburylov/PycharmProjects/scraper/chromedriver')
url = 'https://somesite'
driver.get(url=url)
time.sleep(15)

driver.close()
driver.quit()


What could be wrong? Or maybe there is a better way to bypass the protection?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question