lapoirie matthieu
lapoirie matthieu

Reputation: 1

hcaptcha response using 2captcha python Discord

I am trying to connect to a site that uses Discord authentication. I want to retrieve data, but for this, the authentication sees that it's a bot and during login, it puts up an hCaptcha. I paid for 2captcha and I managed to get the hCaptcha code, but I can't inject it to log in. The hCaptcha just has a checkbox that I don't see in the HTML code. I've tried a lot of things by injecting it into the code, but without a button, I don't know how to validate the hCaptcha.

My code:

    # Inject the CAPTCHA response into the field
    # Trouver l'élément de réponse CAPTCHA
    captcha_response_element = driver.find_element(By.NAME, 'h-captcha-response')

    # Inject the CAPTCHA response into the field
    try:
        driver.execute_script("document.querySelector('[name=\"h-captcha-response\"]').innerHTML = arguments[0];", code)
        print("CAPTCHA response injected successfully")
    except Exception as e:
        print(f"Error injecting CAPTCHA response: {e}")

    soup = BeautifulSoup(driver.page_source, 'html.parser')
    print(soup)

    try:
        WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((By.CSS_SELECTOR, "button.close_d10a58"))
        )
    except Exception as e:
        print(f"Error waiting for button")
        driver.quit()
        exit()
    driver.find_element(By.CSS_SELECTOR, "button.close_d10a58").click()

    print("OK captcha")

and the result of BeautifulSoup(driver.page_source, 'html.parser')

Log in with QR CodeScan this with the Discord mobile app to log in instantly.Or, sign in with passkeyWait! Are you human?Please confirm you’re not a robot.window.__OVERLAY__=/overlay/.test(location.pathname)window.__BILLING_STANDALONE__=/^\/billing/.test(location.pathname) (function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.nonce='NzUsNTgsMjI2LDExMCwxNjgsMTQ2LDExMSwyNDY=';d.innerHTML="window.__CF$cv$params={r:'909857d89a98ecd6',t:'MTczODE0NDQ5MC4wMDAwMDA='};var a=document.createElement('script');a.nonce='NzUsNTgsMjI2LDExMCwxNjgsMTQ2LDExMSwyNDY=';a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();,,Reactionsclick to open image dialog

Upvotes: 0

Views: 65

Answers (0)

Related Questions