How to bypass slider CAPTCHA with Python+Selenium?

rsrx

Newbie
Joined
Jul 4, 2018
Messages
1
Reaction score
0
Hi, everyone, I'm trying to bypass Hotbit CAPTCHA. I've been trying to do this with Selenium, however website somehow recognizes it's ran by automation and declines CAPTCHA resolve.

Even when I try to solve CAPTCHA manually (but launch browser session programatically), it fails.

If I launch browser manually, then attach Selenium webdriver to the session, manual CAPTCHA resolve works.

So I'm guessing website is detecting something weird in how browser session is launched?

Here is the full code:

Code:
import time
import os
import random
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.common.by import By


class Hotbit:
    username = None
    password = None
    browser = None

    def __init__(self, username, password):
        # iniitialize class and attempt to login
        self.username = username
        self.password = password
        self.init_driver()
        self.login()

    def init_driver(self):
        # initialize webdriver
        options = webdriver.ChromeOptions()
        # options.headless = True
        options.add_argument('--user-data-dir=c:\\Users\\rsrx\\appdata\\Local\\Google\\Chrome\\User Data\\')
        self.browser = webdriver.Chrome(executable_path='./drivers/chromedriver.exe', options=options)

    def login(self):
        # load login page
        try:
            print('Loading login page...')
            self.browser.get(login_page_url)
            WebDriverWait(self.browser, 15).until(ec.presence_of_element_located((By.ID, 'nc_1_n1z')))
        except TimeoutException:
            print('Load timeout')
            return False

        # solve CAPTCHA
        print('Resolving CAPTCHA...')
        print(self.drag_slider())

    def drag_slider(self):
        slider = self.browser.find_element_by_id('nc_1_n1z')
        slider.click()
        ac = ActionChains(self.browser)
        ac.move_to_element(slider)
        ac.click_and_hold(slider)
        xoffset = 0
        while xoffset < 350:
            xmove = random.randint(10, 50)
            ymove = random.randint(-1, 1)
            ac.move_by_offset(xmove, ymove)
            xoffset += xmove
        ac.release()
        ac.perform()

        time.sleep(3)

        element = self.browser.find_element_by_class_name('nc-lang-cnt')
        print(element.text)

if __name__ == '__main__':
    hotbit = Hotbit('username', 'password')

I am a new member so can't type website links but you should replace "login_page_url" in the code with hotbit.io/login URL.

Any ideas would be appreciated. Thanks.
 
Last edited:
The bot detection tests for pre-defined javascript variables that the webdriver creates, the usually only look for obvious ones like variables names containing "selenium" or "webdriver", but the exact names depends on the browser and the version of the webdriver, luckily you can open the webdriver on a text editor look for the variables and rename them.
Extra tip: also rename the variables named $cdc_ and $wdc_
 
use anticaptcha service or deadcaptcha they will provide their custom code
 
Have you looked at StackOverflow? There are a lot of threads about bypassing slider captchas with Selenium or just Javascript (you can execute Javascript while using Selenium).
 
It's impossible to bypass captcha without using third-party services like Anticaptcha or Capmonster.
Anyway, if you're gonna solve a little number of captchas (10000- 15000) then your best choice, in my opinion, is Anticaptcha or 2captcha because they will cost less than Capmonster for small number of captchas but if you have a large number (20000+) of captchas then you have to buy Capmonster software because it solves unlimited number and you pay monthly. Both solutions are very easy to integrate with selenium.
 
The bot detection tests for pre-defined javascript variables that the webdriver creates, the usually only look for obvious ones like variables names containing "selenium" or "webdriver", but the exact names depends on the browser and the version of the webdriver, luckily you can open the webdriver on a text editor look for the variables and rename them.
Extra tip: also rename the variables named $cdc_ and $wdc_

How do you edit an exe file with a text editor. i need to solve this problem!
 
It's impossible to bypass captcha without using third-party services like Anticaptcha or Capmonster.
Anyway, if you're gonna solve a little number of captchas (10000- 15000) then your best choice, in my opinion, is Anticaptcha or 2captcha because they will cost less than Capmonster for small number of captchas but if you have a large number (20000+) of captchas then you have to buy Capmonster software because it solves unlimited number and you pay monthly. Both solutions are very easy to integrate with selenium.
but anticaptcha not supplied the solution to slider captcha . I don't know can Capmonster solve that ?
 
I recommended you 2Captcha, They're Api is easy to use and well documented!
 
Back
Top