Using 2captcha Service got attribute error

43 views Asked by At

I install the 2cpatcha buy using these command pip install 2captcha-python but they give me these error TwoCaptcha' object has no attribute 'normal' is there any solution kindly recommend that

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from twocaptcha import TwoCaptcha

driver = webdriver.Chrome("C:\Program Files (x86)\chromedriver.exe")
driver.get('https://www.amazon.com')

time.sleep(2)
# Locate and capture the CAPTCHA element
captcha_element = driver.find_element(By.XPATH, "//img[@class='_2hXzbgz7SSP0DXCyvKWcha']")
captcha_element.screenshot('captcha/captcha.png')

time.sleep(2)
# Set up 2Captcha solver
api_key = os.getenv('APIKEY_2CAPTCHA', '-------')
solver = TwoCaptcha(api_key)

try:
    # Solve CAPTCHA
    result = solver.normal('captcha/captcha.png')

# except Exception as e:
except Exception as e:
    print("2Captcha API is not working:", e)
else:
    print(result)
0

There are 0 answers