I am getting the error ERROR_CAPTCHA_UNSOLVABLE
while using the 2captcha API
service to solve a google recaptcha.
When I manually solve this captcha I have to click the check box and then select the images and then click on verify button. Here is how I am trying to solve this captcha and I am using selenium to get elements.
WebDriverWait(driver,23).until(EC.presence_of_all_elements_located((By.XPATH,'//div[@class="g-recaptcha"]')))
google_recaptcha = driver.find_element(By.XPATH,'//div[@class="g-recaptcha"]').get_attribute('data-sitekey')
print("SOLVING CAPTCHA")
print(google_recaptcha)
result = solve(google_recaptcha,url)
result = result['code']
WebDriverWait(driver,10).until(EC.presence_of_all_elements_located((By.ID,'g-recaptcha-response')))
driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML = "+"'"+result+"'")
and here is my solve
function
def solve(siteKey,url):
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
api_key = os.getenv('APIKEY_2CAPTCHA', 'adsasd')
solver = TwoCaptcha(api_key)
try:
result = solver.recaptcha(
sitekey=siteKey,
url='https://2captcha.com/demo/recaptcha-v2')
except Exception as e:
print(e)
else:
return result
I am passing the current tab URL and the site key. but whenever I try this I get the exception ERROR_CAPTCHA_UNSOLVABLE. Is there any other way to solve this or I am in the wrong direction? Please guide me I am very new to this.