小编sim*_*ple的帖子

Selenium headless:如何使用 Selenium 绕过 Cloudflare 检测

希望专家能帮助我解开 Selenium/Cloudflare 之谜。我可以让一个网站在普通(非无头)Selenium 中加载,但无论我尝试什么,我都无法让它在无头中加载。

我已遵循 StackOverflow 帖子中的建议,例如Is there a version of Selenium WebDriver that is not detectorable? window我还查看了和对象的所有属性window.navigator,并修复了无头和非无头之间的所有差异,但不知何故仍然检测到无头。此时我非常好奇 Cloudflare 如何能够找出其中的差异。谢谢你的时间!

我尝试过的事情列表:

  • 用户代理
  • 替换cdc_为 chromedriver 中的另一个字符串
  • options.add_experimental_option("excludeSwitches", ["enable-automation"])
  • options.add_experimental_option('useAutomationExtension', False)
  • options.add_argument('--disable-blink-features=AutomationControlled')(这是让网站以非无头方式加载所必需的)
  • navigator.webdriver = undefined
  • 设置navigator.pluginsnavigator.languages、 和navigator.mimeTypes
  • window.ScreenY, window.screenTop, window.outerWidth,设置window.outerHeight为非零
  • 设置window.chromewindow.navigator.chrome
  • 将图像的宽度和高度设置为非零
  • 设置WebGL参数
  • 使固定Modernizr

重复实验

为了让网站在正常(非无头)Selenium 中加载,您必须点击_blank另一个网站的链接(以便目标网站在另一个选项卡中打开)。要复制该实验,首先创建一个包含内容的 html 文件<a href="https://poocoin.app" target="_blank">link</a>,然后在以下代码中粘贴该 html 文件的路径。

下面的版本(非无头)运行良好并加载网站,但如果您设置 …

python selenium bots webdriver selenium-webdriver

35
推荐指数
1
解决办法
6万
查看次数

标签 统计

bots ×1

python ×1

selenium ×1

selenium-webdriver ×1

webdriver ×1