selenium - 如何在 chromedriver 中禁用“navigator.webdriver”?
问题描述
在寻找方法数小时后,我无法找到任何可行的方法。
我能找到的唯一方法是将“pageLoadingStrategy”功能值设置为“eager”,然后立即执行一些 javascript,以便它可以在页面呈现之前更改navigator.webdriver值。但是您需要在每次请求后更改该值,这并不可靠。
在执行任何请求之前如何设置它?有国旗吗?
解决方案
在查看了 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
希望这对也遇到此问题的人有所帮助。感谢您的关注
推荐阅读
- django - Django:如何过滤并获取包含所有搜索关键字的结果
- node.js - 使用 botium-cli 运行自定义示例时找不到 webdriver 模块?
- javascript - 测试库无法设置只有 getter 的 [object Object] 的属性错误
- python - 是否可以在进程之间共享一个不为空的 numpy 数组?
- c - 编译模块时找不到linux文件夹中的头文件time_types.h
- python - 在 numba 中使用 numpy 随机选择
- firebase - Firestore 规则以检查用户 Cloud Firestore 中是否存在用户喜欢的帖子
- python - 来自客户端系统的 Grep 路由器 ARP 表,无需使用 python 登录路由器主页
- python - 提取br标签美汤python
- java - 无法解析的日期 - 在 java 中