[Python] Solving Arkoselabs FunCaptcha using 2captcha api. (Captcha incorrect)

Discussão em 'Python' iniciado por Stack, Abril 22, 2025.

  1. Stack

    Stack Membro Participativo

    I'm experiencing issues with solving a CAPTCHA using the 2Captcha service. Here’s a breakdown of my situation:

    Expected Outcome:
    I expected the CAPTCHA to be solved correctly each time, resulting in successful validation after submitting the CAPTCHA token.

    Actual Outcome:
    Despite following the correct procedure, I receive an incorrect response where one answer is always wrong while the rest are correct. To resolve the issue, I contacted 2Captcha support, and they recommended blocking the CAPTCHA rendering on my end to avoid incorrect data parameters. I implemented their advice, but the problem still persists.

    Technical Details:
    I am using the following method to solve the CAPTCHA:

    def solve_captcha(public_key, page_url, blob,driver):
    time.sleep(20)
    task_payload = {
    "clientKey": APIKEY,
    "task": {
    "type": "FunCaptchaTaskProxyless",
    "websiteURL": page_url,
    "websitePublicKey": public_key,
    "funcaptchaApiJSSubdomain": "roblox-api.arkoselabs.com",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
    "data": {"blob": blob}
    }
    }

    try:
    response = requests.post(f"{APIURL_2CAPTCHA}/createTask", json=task_payload).json()
    if response.get("errorId") != 0:
    print(f"Error creating task: {response}")
    return None

    task_id = response.get("taskId")
    print(f"Task created successfully. Task ID: {task_id}")

    for attempt in range(30):
    print(f"Checking task status... Attempt {attempt + 1}/30")
    time.sleep(10)
    result = requests.post(f"{APIURL_2CAPTCHA}/getTaskResult", json={"clientKey": APIKEY, "taskId": task_id}).json()
    print(result)

    if result.get("status") == "ready":
    token = result.get("solution", {}).get("token")
    print(f"Captcha solved successfully! Result token: {token}")
    return token, task_id

    elif result.get("errorCode") == "ERROR_CAPTCHA_UNSOLVABLE" :
    print("Error: Captcha is unsolvable.")
    break
    else:
    print("Captcha not ready yet, retrying...")
    print("Task timed out or failed.")
    driver.refresh()
    TryLogin(driver=driver)
    startCaptchaProccess(driver=driver, ver="2CAPTCHA")
    except Exception as e:
    print(f"failed somewhere in the solve captcha proccess. {e}")
    return None


    I’m also intercepting the URL to block the CAPTCHA rendering as follows:

    blocked_urls = [
    "https://arkoselabs.roblox.com/rtig/image?challenge"
    ]

    def interceptor(request):
    if any(blocked in request.url for blocked in blocked_urls):
    print(f"Intercepting and faking 200 OK for: {request.url}")

    # Create fake 200 response
    request.create_response(
    status_code=200,
    headers={'Content-Type': 'image/png'},
    body=b'Haha you stinky i faked'
    )

    url = request.url
    if url and "publicKey=" in url:
    publicKey = url.split("publicKey=")[1].split("&")[0]
    Blob = url.split("dataExchangeBlob=")[1].split("&")[0]
    print(f"Public key: {publicKey}")
    print(f"Blob: {Blob}")
    print("starting to solve captcha")

    token, task_ID = solve_captcha(publicKey, page_url=driver.current_url, blob=Blob, driver=driver)

    if token:
    print("Injecting token..")
    submit_captcha(driver, token, task_ID)


    When I submit the token with this snippet:

    captcha_input = driver.find_element(By.ID, "FunCaptcha-Token")
    driver.execute_script("arguments[0].setAttribute('value', arguments[1])", captcha_input, token)
    print("Captcha token injected successfully!")
    try:
    time.sleep(2)
    for x in range(10):
    button = driver.find_element(By.XPATH, "//button[text()='Submit']")
    button.click()
    time.sleep(5)
    print("Captcha form submitted!")
    try:
    driver.find_element(By.XPATH, "//button[text()='Try again']")
    print("Captcha solved was inncorect. Reloading..")
    driver.refresh()
    TryLogin(driver=driver)
    startCaptchaProccess(driver=driver, ver="2CAPTCHA")
    except:
    pass


    I repeatedly get a message indicating that the CAPTCHA was solved incorrectly, prompting me to reload the page.

    Screenshot of Results:


    [[The resut after submiting the captcha](https://i.sstatic.net/26fVVxyM.png)](https://i.sstatic.net/9na4IgKN.png)

    Request for Help:
    Can anyone suggest additional troubleshooting steps or modifications to my code that might resolve the issue?

    Thanks in advance for your assistance!

    Continue reading...

Compartilhe esta Página