首页 > 解决方案 > 如何在 chromedriver 中禁用“navigator.webdriver”?

问题描述

在寻找方法数小时后,我无法找到任何可行的方法。

我能找到的唯一方法是将“pageLoadingStrategy”功能值设置为“eager”,然后立即执行一些 javascript,以便它可以在页面呈现之前更改navigator.webdriver值。但是您需要在每次请求后更改该值,这并不可靠。

在执行任何请求之前如何设置它?有国旗吗?

标签: seleniumselenium-chromedriver

解决方案


在查看了 chrome 源代码一段时间后,我终于弄清楚需要使用什么标志来禁用该 navigator.webdriver 滋扰。

这是启动chromedriver时需要使用的标志。它甚至完全禁止“webdriver = true”出现。:)

--disable-blink-features=AutomationControlled

这里还有一些可以启用/禁用的功能。

特征

Enable Flag:
--enable-blink-features=example1,example2,example3

Disable Flag
--disable-blink-features=example1,example2,example3

希望这对也遇到此问题的人有所帮助。感谢您的关注


推荐阅读