python - Selenium with/Firefox 88 更改为 navigator.webdriver

标签 python selenium selenium-webdriver firefox web-scraping

Firefox 88 的最新版本包括 bug fix如果浏览器通过 marionette 协议(protocol)运行,则用户将无法将 navigator.webdriver 属性设置为 false。不幸的是,如果站点使用像 Cloudflare 的 DDOS 保护这样的服务来检查远程浏览器上的该属性并陷入无限循环,而不是重定向到请求的页面,那么这会有效地使某些网络抓取事件变得不可能。
现在有人知道替代方法吗

profile.set_preference("dom.webdriver.enabled", False)
或者
profile.set_preference("useAutomationExtension", False)
现在有没有效果?
具体来说,我将 Selenium 与 Python 绑定(bind)一起使用,但我想使用任何框架的解决方法都可以适用于我的情况。

最佳答案

我尝试向 Firefox 添加扩展,它会在加载任何其他脚本之前覆盖 navigator.webdriver。似乎它不仅与 navigator.webdriver 有关,而且与其他一些东西有关。
我在 document_start 上执行了以下代码script = document.createElement("script"); script.type = 'text/javascript'; script.id = "scripttttttt"; script.innerHTML = "Object.defineProperty(navigator, 'webdriver', {get: () => undefined});document.getElementById('scripttttttt').remove();"; document.documentElement.prepend(script);这足以打开https://ebay-kleinanzeigen.de/m-einloggen.html但不足以登录 Google 帐户。

关于python - Selenium with/Firefox 88 更改为 navigator.webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67323487/

相关文章:

python - Pandas 数据框将唯一值转换为列名

python - 基础 Python : Rank items in list

python - 如何将 PyTorch 张量分块到指定的桶大小并重叠?

java - 我们如何使用 Selenium WebDriver 获得加载页面的准确时间?

java - Firefox 错误 : "Your connection is not secure" while launching driver with Selenium 3. 0.1 使用 Java

testing - 使用不同输入文件的数据驱动自动化测试

Python 类 : How to add a custom method to an existing object (pandas dataframe)

selenium - Selenium 的最小 perl 脚本是什么?

c# - 无法在 selenium webdriver 中找到::之前的 css 选择器元素

java - Cucumber 和 TestNG 参数冲突