-2

I'm trying to login to a website, but it seems to be blocking me based solely off of me using selenium to login. The code I am using is below, but I am sure that the problem isn't with the code as the login fails even if I open the selenium browser window and login completely manually.

driver = webdriver.Firefox()
driver.get("https://www.etoro.com/login/?")
sleep(5)
driver.find_element_by_id("username").send_keys(username)
driver.find_element_by_id("password").send_keys(password)
driver.find_element_by_xpath('//button[@automation-id="login-sts-btn-sign-in"]').click()

Having looked this up, this seems similar to how google have blocked logging in to gmail if you use a browser that supports automation; but that has some kind of workaround, while I haven't found a similar workaround for this website. Any help much appreciated.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
RichKat
  • 57
  • 1
  • 8
  • They don't want your script on their site. Respect that and move on. – JeffC Feb 09 '21 at 17:38
  • But I'm not like posting fake comments or something. I just want to automate an action I do daily. – RichKat Feb 09 '21 at 17:43
  • Clearly they don't care. Have you looked at their Terms & Conditions? Most sites like that strictly forbid bots and scripts on their site for any purpose. If they wanted bots to have access, they wouldn't block you. You might check and see if they have a API available to do your desired tasks. – JeffC Feb 09 '21 at 22:50

2 Answers2

2

This website probably has a robot detection, so they probably don't want you to log in that way. However these robot detection scripts will probably check various things like CSRF tokens, the user-agent string and maybe even the mouse behavior, typing speed and event originators. You could try a combination of webdriver and manual input.

Here is a reddit post that explains a very similar problem: https://www.reddit.com/r/hacking/comments/aayjd3/how_to_bypass_a_website_blocking_automated_tasks/

anonimostilton
  • 170
  • 1
  • 16
0

I didn't observe and blocking measure while trying to login using Selenium driven GeckoDriver initiated Browsing Context.


To initiate logging within the website you can use the following Locator Strategies:

  • Using CSS_SELECTOR:

    driver.get('https://www.etoro.com/login/?')
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#username"))).send_keys("RichKat")
    driver.find_element(By.CSS_SELECTOR, "input#password").send_keys("RichKat")
    driver.find_element(By.CSS_SELECTOR, "button.ng-binding").click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
  • Browser Snapshot:

etoro_com

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352