Submit a reCAPTCHA token with Python HTTPX
Use solution.token, the successful solve proxy, and the returned browser identity when posting to the target. Keep the application's cookies in one HTTPX client; a valid token doesn't replace its session or CSRF requirements.
On this page
Send the ready token through the successful proxy
Install HTTPX with pip install httpx. The example also uses the official Python SDK; see Python SDK setup if it isn't installed.
The example includes the solve call to show where the result comes from. If you already have a ready SDK result, reuse it as result alongside the original request. Don't create another task just to submit its token.
- Set
SOLVETHREE_API_KEYto your workspace API key andSOLVETHREE_PROXYto the proxy URL. Keep the API key on the server. - Replace
accounts.example.com, theloginaction and the submission URL with your intended target's values. The hostname needs an active site profile in your workspace; see site profile setup. - Adapt the form fields to the application's actual request. The example sends only the CAPTCHA field, not a complete login form.
# pip install httpx and the official solvethree SDK wheel.
import os
import httpx
from solvethree import Solvethree, successful_proxy
request = {"site": "accounts.example.com", "action": "login", "proxy": os.environ["SOLVETHREE_PROXY"]}
result = Solvethree(os.environ["SOLVETHREE_API_KEY"]).solve(request, timeout=180)
solution = result["solution"]
proxy = successful_proxy(request, result)
if proxy is None:
raise RuntimeError("No valid successful proxy")
with httpx.Client(proxy=proxy, timeout=30, follow_redirects=False, trust_env=False) as target:
# Use this client's cookie jar for any required application session first.
response = target.post("https://accounts.example.com/login",
data={"g-recaptcha-response": solution["token"]},
headers={"User-Agent": solution["userAgent"], "sec-ch-ua": solution["secChUa"]})
print("Application HTTP status:", response.status_code)
# Check the application's actual response and required CSRF/session fields.successful_proxy(request, result) selects the proxy to reuse for submission. Keep the check that stops submission if it returns no valid proxy. Use HTTPX's current singular proxy= parameter, not proxies=. Setting trust_env=False prevents environment proxy settings from changing the explicitly selected route.
Keep cookies, browser identity and form fields together
If the application requires an initial page request to establish a session or obtain a CSRF value, make that request inside the same HTTPX client before the POST. Its cookie jar retains cookies across requests. A separate client won't automatically have that session.
Use the returned userAgent and secChUa for those preliminary requests too, not an unrelated browser identity. The example supplies them on the POST as User-Agent and sec-ch-ua. Keep those headers and the successful proxy consistent when submitting the solution to its intended target.
data= sends form data. Here, g-recaptcha-response receives solution.token; it must not receive the task ID or the whole solution dictionary. Match the field name to the target's actual request, and include any required credentials, hidden fields and CSRF value in that same submission.
Inspect redirects before treating the submission as successful
follow_redirects=False leaves the first application response visible. If it redirects, inspect its status and destination before explicitly following the application's expected next step with the same client. Don't automatically resend the token to a different URL.
The printed HTTP status is only a starting point. Check the response body, redirect destination or resulting application state to determine whether the target accepted the request. A 200 response or a redirect can represent either success or an error flow; solvethree's ready status means a solution was generated, not that the target accepted it.
Sources and API reference
Run your first task.
Start with $5 in workspace credit.