0

I am building an analysis bot for an io game called diep.io. I am attempting to open diep.io in Ubuntu, using Python. Using Selenium to open Firefox, but I have the same problem with Chrome as well.

The code:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://diep.io')
input() # to prevent auto-closure

It seems really simple so I don't get what's going on. When I open the browser manually and navigate to diep.io it works normally, but when I open it with Selenium it runs very slowly, and doesn't show the 'enter your name here' box.

To be clear, I have geckodriver installed correctly, and I'm pretty certain I have the most current version of Python, Selenium, and Firefox. Other webpages work well enough, though they are kinda slow as well.

I can show screenshots or log files if it's needed to diagnose the issue. Any help is appreciated. Thanks.

Noah Smith
  • 101
  • 2

2 Answers2

0

The problem is that the website detects your bot, you can check the network tab after firing your bot; it also uses cloudflare's protection

AYehia0
  • 33
  • 4
0

To send a text within the <input> field e.g. Doremon and press ENTER you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following locator strategies:

  • Code Block:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.chrome.service import Service
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
    options = Options()
    options.add_argument("start-maximized")
    s = Service('C:\\BrowserDrivers\\chromedriver.exe')
    driver = webdriver.Chrome(service=s, options=options)
    driver.get("https://diep.io/")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#textInput"))).send_keys("Doremon" +Keys.RETURN)
    
  • Browser Snapshot:

Doremon

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