ad-m / python-anticaptcha

Client library for solve captchas with Anticaptcha.com support.
http://python-anticaptcha.readthedocs.io/en/latest/
MIT License
223 stars 51 forks source link

Selenium Not reachable element #52

Closed PaulGhibs closed 4 years ago

PaulGhibs commented 4 years ago

Hello adam , first of all thanks for your repository it is really helpful! I'm trying to bypass the captcha on this website https://www.similarweb.com/ to make automated tests

The thing is no matter which one i choose its always says NoSuchElementException: Message: Unable to locate element: #recaptcha-verify-button here is my code do you have any ideas

!/usr/bin/env python

coding: utf-8

from selenium import webdriver from selenium.webdriver import Firefox

from selenium.webdriver.firefox.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask import os import time

api_key = '****'

set your account / password

email = '**' password = ''

Open web-browser

options = Options()

options.add_argument('-headless')

driver = Firefox(options=options) driver.get('https://account.similarweb.com/login') driver.find_element_by_css_selector('#UserName--1').send_keys(email) driver.find_element_by_css_selector('#Password--2').send_keys(password) driver.find_element_by_css_selector('#authApp > main > div > div.login__authbox > form > button').click()

Save required variables

url = driver.current_url site_key = '6LfEq1gUAAAAACEE4w7Zek8GEmBooXMMWDpBjI6r'

Send site-key to Anti-captcha

client = AnticaptchaClient(api_key) task = NoCaptchaTaskProxylessTask(url, site_key) job = client.createTask(task) print("Waiting to recaptcha solution") job.join()

Receive response

response = job.get_solution_response() print("Received solution", response)

Inject response in webpage

driver.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "%s"' % response)

Wait a moment to execute the script (just in case).

time.sleep(1)

Press submit button

driver.find_element_by_css_selector('#recaptcha-verify-button').click()

ad-m commented 4 years ago

Hello,

I have developed a solution for Similiarweb. The code is available on: https://github.com/ad-m/python-anticaptcha/blob/tidal/examples/real-cases/similiarweb.py

In case of problems - let me know. I hope it will help your problem.

Greetings,

ad-m commented 4 years ago

No response, so I am going to close that issue. Feel free to reply if this issue is still relevant for you.