1

Before this gets taken down as a duplicate, I have already tried all of the options available here: Is there a version of Selenium WebDriver that is not detectable?.

I am trying to create a Selenium bot in Python which can successfully login without getting blocked due to bot detection. My current script is below and I have created a test account for anyone to access and help me get this working. The correct answer here would ideally be a working version of this script that I can use.

Username: TestAccount
Password: StackOverflowPass1

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import time
 
##### open depop 'likes' page #####

url = "https://www.depop.com/login/"

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get(url)

driver.implicitly_wait(2)
driver.get(url)
time.sleep(2)

accept_cookies = driver.find_element_by_xpath('/html/body/div[1]/div/div[3]/div[2]/button[2]')
accept_cookies.click()
time.sleep(2)

username = driver.find_element_by_xpath('/html/body/div[1]/div/div/div[1]/form/div[1]/input')
username.send_keys('TestAccount1')

password = driver.find_element_by_xpath('/html/body/div[1]/div/div/div[1]/form/div[3]/div/input')
password.send_keys('StackOverflowPass1')

login_button = driver.find_element_by_xpath('/html/body/div[1]/div/div/div[1]/form/button')
login_button.click()
lewisnix21
  • 111
  • 2
  • 7

1 Answers1

2

I have had the same issue with logging in to gmail. I could not solve it for a week. I am 99% sure that you can't bypass the bot detection. How I solved it:

I have created Chrome account to which my gmail will be logged in all the time (disabled 2FA). Then I just start chrome as that user. Bot detection was no more an issue when I was already logged into gmail. Maybe you should try the same, add this command to your driver class:

options.add_argument("user-data-dir=/Users/alexiseggermont/Library/Application Support/Google/Chrome/Default/")

This path is usable for Mac or Linux OS. Also, rename "Default" to your profile id (for me, and in most cases, it was "Profile 1")

Funky Monkey
  • 121
  • 5
  • 1
    Oh my god, it worked! Thank you so much. For those who are in a similar situation in the future, just to flesh Josip's answer out a little more, I had to go to chrome://version/ in my chrome browser and copy the profile path which for me was "C:\Users\lewis\AppData\Local\Google\Chrome\User Data\Default". One final step was to remove the "\Default". All in all my missing lines were: options = webdriver.ChromeOptions() options.add_argument("--user-data-dir=C:/Users/lewis/AppData/Local/Google/Chrome/User Data") driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options) – lewisnix21 Jan 31 '22 at 14:33
  • 1
    I am really happy to help :) So glad it worked. Keep grinding and good luck! :D – Funky Monkey Feb 02 '22 at 16:30