Python/Selenium - 站点检测到我正在使用驱动程序并阻止访问

Python/Selenium - Site is detecting I am using driver and blocking access

提问人:gvphubli.blogspot.com 提问时间:9/7/2023 更新时间:9/7/2023 访问量:43

问:

我正在使用适用于 Chrome 的 Python 2.7 和 Selenium 驱动程序。我已经对各种网站进行了大量自动化,其中包括 iFrame/login/OTP 等,即说我知道我解决这些事情的方式。

现在,我遇到了一种情况,即当我通过硒驱动程序打开 Chrome 时,股票经纪人网站使用某种机器人检测(我猜),即使我单击(以确保设置了 cookie 和其他变量),然后使用用户 ID 和密码手动登录 - 它无法对我进行身份验证(显示消息“无效的登录 ID 或密码”)

这周围有什么吗?(规避驾驶员检测)?还是别的什么?

我尝试搜索该网站的 javascripts/html 源代码以查看此类内容的任何线索,但我没有看到类似的东西。

非常感谢任何帮助,我将此自动化用于个人用途,不会对这些目标系统造成任何压力。

python-2.7 selenium-web驱动程序

评论


答:

0赞 Yaroslavm 9/7/2023 #1

您可以尝试使用驱动程序。undetected selenium

它的实现是为了避免 CloudFlare / Captcha / 机器人检测场景。 它不适用于所有情况,但它可以通过大多数机器人检测检查。

(请注意,您需要将 Python 升级到3.6+)

import undetected_chromedriver as uc
from undetected_chromedriver import ChromeOptions

options = ChromeOptions() # your options
driver = uc.Chrome(options)

参考

评论

0赞 gvphubli.blogspot.com 9/11/2023
谢谢,但我不能去 3.6+ 但最后我最终得到了这个解决方案 username = os.getenv(“USERNAME”) userProfile = “C:\\Users\\” + username + “\\AppData\\Local\\Google\\Chrome\\User Data\\Default” options = webdriver。ChromeOptions() options.add_argument(“user-data-dir={}”.format(userProfile)) 从这里 : “stackoverflow.com/a/33396684"