这个网站如何检测带有 selenium 和 chromedriver 的远程控制? [英] How does this website detect remote control with selenium and chromedriver?

查看:72
本文介绍了这个网站如何检测带有 selenium 和 chromedriver 的远程控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 selenium 和 chromedriver 从 Discover 网站筛选我自己的信用卡信息.作为响应,它返回错误:

<块引用>

目前无法访问您的帐户.

过时的浏览器会使您的计算机面临安全风险.要得到Discover.com 上的最佳体验,您可能需要更新您的浏览器到最新版本,然后重试.

有趣的是,如果我编写一个脚本来打开一个带头的浏览器并输入一些随机的帐户和密码,它就可以正常工作.但是如果脚本首先接触网页然后我输入,我会收到上述错误消息.有效的脚本是:

导入时间从硒导入网络驱动程序驱动程序 = webdriver.Chrome()driver.execute_script('window.location.href = "https://portal.discover.com/customersvcs/universalLogin/ac_main";')

如果我将这些行附加到脚本并在睡眠结束后键入,则会失败:

time.sleep(5)driver.find_element_by_id('userid-content').click()

我尝试了其他方法将数据输入到页面中,例如 send_keys 和执行 Javascript 来修改页面,它们都以同样的方式失败.

网站如何检测遥控器?有没有办法绕过它?

解决方案

我已经尝试过你的概念和你的代码块并实现了

  • 但是你点击提交按钮,loginForm是通过JavaScript函数validateForm(this);onsubmit 事件中调用.

  • 令人惊讶的是,即使在 用户凭据 得到验证之前,网站似乎就已检测到 自动登录过程 并发回:

     目前无法访问您的帐户.过时的浏览器会使您的计算机面临安全风险.要在 Discover.com 上获得最佳体验,您可能需要将浏览器更新到最新版本,然后重试.如有问题,请致电 1-800-347-7769 联系我们.我们每周 7 天、每天 24 小时随时待命.

  • 错误截图:


参考

您可以在以下位置找到一些详细的讨论:

I’m trying to screen scrape my own credit card information from the Discover website using selenium and chromedriver. In response it returns the error:

Your account cannot currently be accessed.

Outdated browsers can expose your computer to security risks. To get the best experience on Discover.com, you may need to update your browser to the latest version and try again.

Interestingly, if I write a script to open a headed browser and type in some random account and password, it works normally. But if the script first touches the web page and then I type, I get the above error message. The script that works is:

import time
from selenium import webdriver

driver = webdriver.Chrome()
driver.execute_script('window.location.href = "https://portal.discover.com/customersvcs/universalLogin/ac_main";')

It fails if I append these lines to the script and type after the sleep finishes:

time.sleep(5)
driver.find_element_by_id('userid-content').click()

I’ve tried other ways to enter data into the page, such as send_keys and executing Javascript to modify the page and they all fail the same way.

How can the website detect the remote control? Is there a way to circumvent it?

解决方案

I have tried with your concept and your code block and have realized Yes portal.discover.com is able to detect Automated Logins.

  • One aspect is that filling up the User ID and Password field and even clicking Submit button is still achievable. Here is the relevant code block :

     import time
     from selenium import webdriver
    
     driver = webdriver.Chrome()
     driver.execute_script('window.location.href = "https://portal.discover.com/customersvcs/universalLogin/ac_main";')
     time.sleep(5)
     driver.find_element_by_css_selector("input#userid-content").send_keys("Harold")
     driver.find_element_by_css_selector("input#password-content").send_keys("Harold")
     # driver.find_element_by_css_selector("form#login-form-content input#log-in-button").click()
    

  • Snapshot with filledup User ID and Password field :

  • But one you click on the Submit button, the loginForm is validated through a JavaScript function validateForm(this); invoked at onsubmit event.

  • Amazingly, even before the User Credentials are validated the website seems to be detecting the Automated Login Process and sends back :

      Your account cannot currently be accessed.
      Outdated browsers can expose your computer to security risks. To get the best experience on Discover.com, you may need to update your browser to the latest version and try again.
    
     For questions, please contact us at 1-800-347-7769. We're always available 24 hours a day, 7 days a week.
    

  • Snapshot of the error :


Reference

You can find a couple of detailed discussions in:

这篇关于这个网站如何检测带有 selenium 和 chromedriver 的远程控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆