How does this website detect remote control with selenium and chromedriver?

怎甘沉沦 提交于 2020-07-15 07:57:19

问题


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?


回答1:


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:

  • Can a website detect when you are using selenium with chromedriver?


来源:https://stackoverflow.com/questions/49541251/how-does-this-website-detect-remote-control-with-selenium-and-chromedriver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!