Python. Bypass the captcha (WebScrapping) [7]


As a result of a bloody war between server administrators and bot owners, a truly terrifying weapon was invented, and its name is CAPTCHA. However, there is always a solution.

And his name is anti-captcha. This service gives your captcha to the Indians, and they solve it for a penny.

In this tutorial, we implement authorization on the wax.


To bypass the captcha, we will need an anti-captcha account, and a couple of dollars.

After replenishing the balance, you need to download the plugin in zip format, from here. Throw this plugin into the folder with the future script.

Write the code.

Copy the following code:

from selenium import webdriver
from import WebDriverWait
import time
import json

def acp_api_send_request(driver, message_type, data={}):
    message = {
        'receiver': 'antiCaptchaPlugin',
        'type': message_type,
    return driver.execute_script("""
    return window.postMessage({});
def allow_anticaptcha():
    #loading anticaptcha api
    print("Allow anticaptcha")
    api_anti_captcha_key = "your_anicaptcha_api_key"
        {'options': {'antiCaptchaApiKey': api_anti_captcha_key}}
def pass_captcha_login():
    WebDriverWait(driver, 120).until(lambda x: x.find_element_by_css_selector('.antigate_solver.solved'))
    buttons = driver.find_elements_by_css_selector("button.button-secondary")
    for button in buttons:
        if button.text == "Login":
   #captcha solved

option = webdriver. ChromeOptions()
driver = webdriver. Chrome('chromedriver.exe',chrome_options=option)


In this example, we will try to log in to the wax. Most of the code, I took from here.

The acp_api_send_request function, sends a message to the plugin, more here.

Next, the allow_catcha() passes api_key to the plugin so that it can work. Of course in this line

api_anti_captcha_key = "your_anicaptcha_api_key"

The key needs to be replaced with your own. You can get it in your personal account. It is better not to show this key to anyone.

Wait 10 seconds


Then, pass_captcha_login() waits for the captcha solution, i.e. waits for the element with the class ‘.antigate_solver.solved

I’ve dealt with expectations here.

WebDriverWait(driver, 120).until(lambda x: x.find_element_by_css_selector('.antigate_solver.solved'))

Waits 3 seconds, just in case.


Searches for the Login button, and clicks on it.

buttons = driver.find_elements_by_css_selector("button.button-secondary") 
for button in buttons:
if button.text == "Login": #captcha solved

Now, run the script, and immediately start filling in the login and password fields. After solving the captcha, the bot itself will click on the Login button.


In this example, we managed to implement authorization on the wax, using an anti-captcha. This is a good example, but there no practical benefit from it, because you can log in to the wax without a captcha (via Google or Reddit).

Final result.