0

I used a selenium library for making my own Nike SNKRS Bot in python, which will work in Chrome browser. I chose one of popular webdriver to manage it by selenium. I got stuck on a Nike login page.

Here is my code:

import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.proxy import Proxy, ProxyType
from random_user_agent.user_agent import UserAgent
from selenium.common.exceptions import TimeoutException, WebDriverException
from random_user_agent.params import SoftwareName, OperatingSystem 
import traceback
options = Options()
options.add_argument("--start-maximized")
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_argument('--lang=en')
options.add_experimental_option('useAutomationExtension', False)
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
options.add_argument('user-agent={0}'.format(user_agent))
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1420,1080")
service=Service('C:\\chromedriver_win32\\chromedriver.exe')
driver = webdriver.Chrome(options=options,service=service)
driver.delete_all_cookies()
driver.execute_script('return navigator.webdriver')
driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"})
driver.get('https://www.nike.com')

def send_keys_delay(controller,keys,delay=1):
    controller.click()
    for key in keys:
        controller.send_keys(key)
        time.sleep(delay)
    controller.send_keys(Keys.RETURN)
try:
    elem=WebDriverWait(driver,5).until(
        ec.presence_of_element_located((By.ID,"hf_cookie_text_cookieAccept"))
    )
    print(elem.text)
    elem.click()
except:
    traceback.print_exc()
    driver.quit()
time.sleep(3)
try:
    elem=driver.find_element(By.ID,"hf_title_signin_membership")
    elem.click()
except Exception:
    traceback.print_exc()
    driver.quit()
try:
    elem=WebDriverWait(driver,5).until(
        ec.element_to_be_clickable((By.ID,"username")))
    email="myemail@gmail.com"
    send_keys_delay(elem,email)


except Exception:
    traceback.print_exc()
    driver.quit()

After all, an error message appears on a screen. This error refers to communication with server. Error message is:

Error parsing response from server.

I'm sure that Nike detects my program as a bot and I can't go further.

My question is: Is it possible to make it work using selenium? Or maybe I should try something different?

cigien
  • 57,834
  • 11
  • 73
  • 112
  • Check this thread: https://stackoverflow.com/questions/33225947/can-a-website-detect-when-you-are-using-selenium-with-chromedriver – Alex Karamfilov Nov 12 '22 at 17:28
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Nov 12 '22 at 23:48

1 Answers1

0

in regards to other platforms you can use, you can try puppeteer, its very similar to selenium and they have a stealth plugin to avoid detection as well as a 2captcha plugin in which you link 2captcha account to solve captchas to further avoid detection.

  • I used pyppeteer in my python project, which is similar to puppeteer i JS, I've got same problem. In selenium (code above) I used 2 lines of code, which manage browser navigator, but I don't know how to program this in pyppeteer. I don't even know if it will change anything. I used also stealth plugin to pyppeteer, nothing changed. Any other solutions? – JustDarkForce Nov 19 '22 at 10:17
  • are you running headless? – Samurai6465 Nov 21 '22 at 08:42
  • No, but I tried to run it in headless mode and same problem. I checked that by screenshot – JustDarkForce Nov 21 '22 at 18:39
  • u can try also using UC chrome driver as it removes that "chrome is being controlled by an automation tool" and most websites arent able to detect that it is automated. keep in mind that nike is really tough to automate as they spent lots of $ specifically to anti bot – Samurai6465 Jun 12 '23 at 02:07