首页 > 解决方案 > 如何绕过 Selenium 中的 Cloudflare bot 保护

问题描述

出于教育目的,我需要从网站上获取一些信息,但是由于受到保护,我无法发送请求。我得到了典型的 Checking-your-browser 页面首先出现,然后我被反复重定向。我如何在 python selenium 中绕过这种保护?

标签: pythonseleniumselenium-chromedrivercloudflare

解决方案


我很久以前就遇到过这个问题,我能够解决它。使用下面的代码并享受:)

options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("--disable-blink-features=AutomationControlled")
driver = webdriver.Chrome(options=options, executable_path=r"webdriver\chromedriver.exe")

/////////// edit //////////////////现在不起作用!


推荐阅读