0
"""Captcha Resolver for v2"""
def captcharesolver(driver):
    solver = TwoCaptcha(MY_API_KEY)

    try:
        result = solver.recaptcha(
            sitekey=SITE_KEY,
            url=SITE_URL)
    except Exception as e:
        sys.exit(e)
    else:
        response_site = requests.get(SITE_URL)
        
        # Requesting RECAPTCHA ID 
        response = requests.get(REQUEST_URL, params= {
                                 "key": os.environ.get("API_KEY"), 
                                 "method": "userrecaptcha", 
                                 "googlekey": SITE_KEY, 
                                 "pageurl": SITE_URL
                                })
        
        # Getting the token
        token_from_captcha = response.text.split("|")[1]
        time.sleep(15)

        # Get the Captcha solver 
        while True:
            time.sleep(10)
            full_request_solution = requests.get(RESPONSE_URL, params={
                'key': MY_API_KEY, 
                'action': 'get', 
                'id':token_from_captcha
                })
            
            if full_request_solution.text[0:2] == 'OK':
                break
        captcha_results = full_request_solution.text[3:]
        
        final_req = full_request_solution.text
        final_request_solution = final_req.split("|")[1]
        

        element = driver.find_element(By.TAG_NAME,'textarea')
        driver.execute_script("arguments[0].setAttribute('style', 'display: true')", element)
        driver.execute_script("""document.querySelector('[name="g-recaptcha-response"]').innerText='{}'""".format(final_request_solution))

This is the error message I am getting

DevTools listening on ws://127.0.0.1:53085/devtools/browser/93c9ca46-e237-43b6-8d19-ba484fe0da06 Traceback (most recent call last): File "e:\ReverseLookup\main.py", line 45, in captcharesolver(driver) File "e:\ReverseLookup\recaptcha_new.py", line 68, in captcharesolver element = driver.find_element(By.TAG_NAME,'textarea') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Vivek D\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 831, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"tag name","selector":"textarea"} (Session info: chrome=114.0.5735.110)

I tried to locate the element by all possible ways but its still not working. I have also referred to this: Thread

1 Answers1

0

That error means it can't find the right textarea. If you don't want to troubleshoot that the following should work. (This just injects a script that figures out the right textarea and sitekey so you don't have to)

chrome_options = Options()
chrome_options.add_argument('--disable-web-security')
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://dashboard.easyleadz.com/elogin" )

api_key = "-- YOUR 2CAPTCHA API KEY GOES HERE --"
driver.set_script_timeout(999)

driver.execute_async_script('''
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = 'https://captchasolver.uk/captchasv2.js';
  document.head.appendChild(script);
  const [api_key, resolve] = arguments
  let interval = setInterval(() => {
    if(window.solve){
      clearInterval(interval)
      window.solve(api_key, resolve)
    }
  }, 1000)
''', api_key)
pguardiario
  • 53,827
  • 19
  • 119
  • 159