### geetestProxyon usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/geetest.md Example from geetest_proxyon_example.py showing how to set up the solver with proxy credentials and solve a GeeTest challenge. It prints the result tokens or an error code. ```python from anticaptchaofficial.geetestproxyon import * solver = geetestProxyon() solver.set_verbose(1) solver.set_key("YOUR_API_KEY") solver.set_website_url("https://address.com") solver.set_gt_key("CONSTANT_GT_KEY") solver.set_challenge_key("VARIABLE_CHALLENGE_KEY") solver.set_proxy_address("PROXY_ADDRESS") solver.set_proxy_port(1234) solver.set_proxy_login("proxylogin") solver.set_proxy_password("proxypassword") solver.set_user_agent("Mozilla/5.0") solver.set_soft_id(0) token = solver.solve_and_return_solution() if token != 0: print("result tokens: ") print(token) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### prosopoProxyless usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/prosopo.md Example from the README showing how to set up and use the prosopoProxyless solver. It sets the API key, website URL, and website key, then solves the captcha and prints the token or error. ```python from anticaptchaofficial.prosopoproxyless import * solver = prosopoProxyless() solver.set_verbose(1) solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_soft_id(0) token = solver.solve_and_return_solution() if token != 0: print("token: " + token) print("user-agent: " + solver.get_user_agent()) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### hCaptchaProxyless example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/hcaptcha.md Example usage from hcaptcha_proxyless_example.py. Sets up the solver with key, website URL, website key, user agent, and soft ID, then solves and prints the response or error. ```python from anticaptchaofficial.hcaptchaproxyless import * solver = hCaptchaProxyless() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_user_agent("YOUR FULL USER AGENT HERE") solver.set_soft_id(0) g_response = solver.solve_and_return_solution() if g_response != 0: print("g-response: " + g_response) print("user-agent, use it to post the form: ", solver.get_user_agent()) print("respkey, if any: ", solver.get_respkey()) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Example usage of funcaptchaProxyless Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/funcaptcha.md Complete example from funcaptcha_proxyless_example.py. Sets verbose, key, website URL, website key, and soft ID, then solves and prints the token or error. ```python from anticaptchaofficial.funcaptchaproxyless import * solver = funcaptchaProxyless() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX") solver.set_soft_id(0) token = solver.solve_and_return_solution() if token != 0: print("result token: " + token) print("user-agent: " + solver.get_user_agent()) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Example usage from recaptcha_v2_enterprise_proxyon_example.py Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav2enterprise.md Complete example showing how to configure and run the solver. Sets verbose mode, API key, website URL and key, proxy credentials, user agent, cookies, enterprise payload, and soft ID, then calls solve_and_return_solution and prints the result or error code. ```python from anticaptchaofficial.recaptchav2enterpriseproxyon import * solver = recaptchaV2EnterpriseProxyon() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_address("PROXY_ADDRESS") solver.set_proxy_port(1234) solver.set_proxy_login("proxylogin") solver.set_proxy_password("proxypassword") solver.set_user_agent("Mozilla/5.0") solver.set_cookies("test=true") solver.set_enterprise_payload({"s": "sometoken"}) solver.set_soft_id(0) g_response = solver.solve_and_return_solution() if g_response != 0: print("g-response: " + g_response) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### get_balance usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antinetworking.md Example of using get_balance to check the account balance and print a message if it is too low. ```python from anticaptchaofficial.recaptchav2proxyless import recaptchaV2Proxyless solver = recaptchaV2Proxyless() solver.set_key("YOUR_KEY") balance = solver.get_balance() if balance <= 0: print("too low balance!") ``` -------------------------------- ### altchaProxyon error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/altcha.md Shows how to handle errors when the solver fails. ```python solver = altchaProxyon() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_challenge_url("/path/to/challenge/url") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### Example usage from funcaptcha_proxyon_example.py Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/funcaptcha.md Complete example of using funcaptchaProxyon to solve a FunCaptcha with proxy. Sets verbose mode, API key, website URL, website key, proxy credentials, user agent, and soft ID, then calls solve_and_return_solution and prints the token or error code. ```python from anticaptchaofficial.funcaptchaproxyon import * solver = funcaptchaProxyon() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX") solver.set_proxy_address("PROXY_ADDRESS") solver.set_proxy_port(1234) solver.set_proxy_login("proxylogin") solver.set_proxy_password("proxypassword") solver.set_user_agent("Mozilla/5.0") solver.set_soft_id(0) token = solver.solve_and_return_solution() if token != 0: print("result token: " + token) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### get_credits_balance usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antinetworking.md Example of using get_credits_balance to check the credits balance and print a message if it is too low. ```python credits = solver.get_credits_balance() if credits <= 0: print("too low credits balance!") ``` -------------------------------- ### Basic usage example for turnstileProxyon Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/turnstile.md Shows how to configure the solver with proxy credentials and an action, then solve and print the token or error code. ```python from anticaptchaofficial.turnstileproxyon import * solver = turnstileProxyon() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) solver.set_proxy_login("login") solver.set_proxy_password("password") solver.set_action("login") token = solver.solve_and_return_solution() if token != 0: print("token: " + token) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Example usage from recaptcha_v2_proxyon_example.py Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav2.md Complete example of solving reCAPTCHA v2 with proxy, setting all required parameters and printing the g-response or error code. ```python from anticaptchaofficial.recaptchav2proxyon import * solver = recaptchaV2Proxyon() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_address("PROXY_ADDRESS") solver.set_proxy_port(1234) solver.set_proxy_login("proxylogin") solver.set_proxy_password("proxypassword") solver.set_user_agent("Mozilla/5.0") solver.set_cookies("test=true") solver.set_soft_id(0) g_response = solver.solve_and_return_solution() if g_response != 0: print("g-response: " + g_response) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Example usage of recaptchaV3Proxyless Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav3.md Complete example from recaptcha_v3_proxyless_example.py showing how to set up and solve a reCAPTCHA v3 task. ```python from anticaptchaofficial.recaptchav3proxyless import * solver = recaptchaV3Proxyless() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_page_action("home_page") solver.set_min_score(0.9) solver.set_soft_id(0) g_response = solver.solve_and_return_solution() if g_response != 0: print("g-response: " + g_response) print("user-agent: " + solver.get_user_agent()) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Example usage of make_request Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antinetworking.md Calls make_request to get balance and prints it if successful, otherwise prints the error string. ```python result = solver.make_request("getBalance", {"clientKey": "YOUR_KEY"}) if result != 0: print(result["balance"]) else: print("request failed:", solver.err_string) ``` -------------------------------- ### Install anticaptchaofficial via pip Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/README.md Install the official Anti-Captcha Python library using pip. ```bash pip3 install anticaptchaofficial ``` -------------------------------- ### Error-handling example with optional parameters Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/funcaptcha.md Shows how to set optional js_api_domain and data_blob, then handle failure by printing error_code and err_string. ```python solver = funcaptchaProxyless() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX") solver.set_js_api_domain("client-api.arkoselabs.com") # optional solver.set_data_blob("...blob...") # optional token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### hCaptchaProxyon usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/hcaptcha.md Complete example from hcaptcha_proxyon_example.py. Configures the solver with proxy and website details, then calls solve_and_return_solution. On success prints the g-response, user agent, and respkey; on failure prints the error code. ```python from anticaptchaofficial.hcaptchaproxyon import * solver = hCaptchaProxyon() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_address("PROXY_ADDRESS") solver.set_proxy_port(1234) solver.set_proxy_login("proxylogin") solver.set_proxy_password("proxypassword") solver.set_user_agent("Mozilla/5.0") solver.set_cookies("test=true") solver.set_soft_id(0) g_response = solver.solve_and_return_solution() if g_response != 0: print("g-response: " + g_response) print("user-agent, use it to post the form: ", solver.get_user_agent()) print("respkey, if any: ", solver.get_respkey()) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### geetestProxyon.set_init_parameters Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/configuration.md Sets the initialization parameters for the GeeTest Proxyon solver. Example: {"riskType": "slide"} for v4. ```APIDOC ## geetestProxyon.set_init_parameters ### Description Sets the initialization parameters for the GeeTest Proxyon solver. Example: {"riskType": "slide"} for v4. ### Method set_init_parameters ### Parameters - **init_parameters** (object) - Required - The initialization parameters. Default is {}. ``` -------------------------------- ### altchaProxyon usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/altcha.md Shows how to configure and solve an Altcha challenge with proxy support. ```python from anticaptchaofficial.altchaproxyon import * solver = altchaProxyon() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_challenge_url("/path/to/challenge/url") solver.set_proxy_type("http") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) token = solver.solve_and_return_solution() if token != 0: print("token: " + token) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### GeeTest v3 example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/geetest.md Example usage for solving a GeeTest v3 captcha using geetestProxyless. It sets the API key, website URL, gt key, challenge key, and soft ID, then calls solve_and_return_solution and prints the result tokens or an error. ```python from anticaptchaofficial.geetestproxyless import * solver = geetestProxyless() solver.set_verbose(1) solver.set_key("YOUR_API_KEY") solver.set_website_url("https://address.com") solver.set_gt_key("CONSTANT_GT_KEY") solver.set_challenge_key("VARIABLE_CHALLENGE_KEY") solver.set_soft_id(0) token = solver.solve_and_return_solution() if token != 0: print("result tokens: ") print(token) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### prosopoProxyon usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/prosopo.md Shows how to set up and use the prosopoProxyon solver with proxy settings. It sets the API key, website URL, website key, proxy address, port, login, password, and invisible flag, then solves the captcha. ```python from anticaptchaofficial.prosopoproxyon import * solver = prosopoProxyon() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) solver.set_proxy_login("login") solver.set_proxy_password("password") solver.set_is_invisible(1) token = solver.solve_and_return_solution() if token != 0: print("token: " + token) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Basic example for imagetocoordinates Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/imagetocoordinates.md Shows how to set up the solver with verbose mode, API key, mode, comment, and soft ID, then solve a captcha image and handle the result. The example uses 'points' mode and prints the coordinates or an error code. ```python from anticaptchaofficial.imagetocoordinates import * solver = imagetocoordinates() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_mode("points") solver.set_comment("Select in specified order") solver.set_soft_id(0) coordinates = solver.solve_and_return_solution("coordinates.png") if coordinates != 0: print("coordinates: ", coordinates) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Error handling example for solve_and_return_solution Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antigatetask.md Shows how to handle failure when solve_and_return_solution returns 0. Prints error_code and err_string on failure, otherwise prints cookies and domain from the solution. ```python solver = antigateTask() solver.set_key("YOUR_KEY") solver.set_website_url("http://antigate.com/logintest.php") solver.set_template_name("Sign-in and wait for control text") solver.set_variables({"control_text": "You have been logged successfully"}) result = solver.solve_and_return_solution() if result == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("cookies:", result["cookies"]) print("domain:", result["domain"]) ``` -------------------------------- ### prosopoProxyon error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/prosopo.md Shows how to handle errors when using the prosopoProxyon solver. It checks if the token is 0 and prints the error code and string. ```python solver = prosopoProxyon() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_type("http") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### prosopoProxyless error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/prosopo.md Shows how to handle errors when using the prosopoProxyless solver. It checks if the token is 0 and prints the error code and string. ```python solver = prosopoProxyless() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### High-concurrency worker example using set_poolSize Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antinetworking.md Example showing how to tune the shared session's connection pool and solve multiple images concurrently with a ThreadPoolExecutor. Each worker creates its own imagecaptcha instance and uses the shared pool. ```python solver = imagecaptcha() solver.set_key("YOUR_KEY") solver.set_poolSize(10, 100) # tune the shared session's connection pool from concurrent.futures import ThreadPoolExecutor def solve_one(path): s = imagecaptcha() s.set_key("YOUR_KEY") return s.solve_and_return_solution(path) with ThreadPoolExecutor(max_workers=4) as ex: texts = list(ex.map(solve_one, ["a.jpeg", "b.jpeg", "c.jpeg", "d.jpeg"])) for t in texts: print(t if t != 0 else "failed") ``` -------------------------------- ### Basic example: solve_and_return_solution with AntiGateTask Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antigatetask.md Basic usage from antigate_proxyless_example.py. Configures an antigateTask solver with website URL, template name, variables, optional domains of interest, and soft ID, then calls solve_and_return_solution and prints the solution fields or error code. ```python from anticaptchaofficial.antigatetask import * solver = antigateTask() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("http://antigate.com/logintest.php") solver.set_template_name("Sign-in and wait for control text") solver.set_variables({ "login_input_css": "#login", "login_input_value": "test login", "password_input_css": "#password", "password_input_value": "test password", "control_text": "You have been logged successfully" }) # optional if you want to collect cookies from domains other than task URL solver.set_domains_of_interest(['domain1.com', 'domain2.com']) solver.set_soft_id(0) result = solver.solve_and_return_solution() if result != 0: cookies, localStorage, fingerprint, url, domain = result["cookies"], result["localStorage"], result["fingerprint"], result["url"], result["domain"] print("cookies: ", cookies) print("localStorage: ", localStorage) print("fingerprint: ", fingerprint) print("url: " + url) print("domain: " + domain) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### friendlyCaptchaProxyless usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/friendlycaptcha.md Example from README showing how to use friendlyCaptchaProxyless to solve a Friendly Captcha. It sets verbose mode, API key, website URL, website key, and soft ID, then prints the token or error. ```python from anticaptchaofficial.friendlycaptchaproxyless import * solver = friendlyCaptchaProxyless() solver.set_verbose(1) solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_soft_id(0) token = solver.solve_and_return_solution() if token != 0: print("token: " + token) print("user-agent: " + solver.get_user_agent()) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Example usage of recaptchaV2EnterpriseProxyless Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav2enterprise.md Example from recaptcha_v2_enterprise_proxyless_example.py. Configures the solver with verbose mode, key, website URL, website key, and soft ID; optionally sets enterprise payload. Calls solve_and_return_solution and prints the g-response or the error code on failure. ```python from anticaptchaofficial.recaptchav2enterpriseproxyless import * solver = recaptchaV2EnterpriseProxyless() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") # solver.set_enterprise_payload({"s": "sometoken"}) solver.set_soft_id(0) g_response = solver.solve_and_return_solution() if g_response != 0: print("g-response: " + g_response) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Usage example for recaptchaV3EnterpriseProxyless Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav3.md Complete example showing how to configure and solve a reCAPTCHA v3 Enterprise task. Set the API key, website URL, website key, page action, and min score, then call solve_and_return_solution. On failure, the error code is printed. ```python from anticaptchaofficial.recaptchav3enterpriseproxyless import * solver = recaptchaV3EnterpriseProxyless() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_page_action("login") solver.set_min_score(0.9) g_response = solver.solve_and_return_solution() if g_response != 0: print("g-response:", g_response) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Turnstile solving example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/turnstile.md Shows how to instantiate turnstileProxyless, set required parameters, optionally set action and cData/chlPageData tokens, and retrieve the token. On success, prints the token and user-agent; on failure, prints the error code. ```python from anticaptchaofficial.turnstileproxyless import * solver = turnstileProxyless() solver.set_verbose(1) solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") # Optionally specify page action solver.set_action("login") # Optionally specify cData and chlPageData tokens for Cloudflare pages # solver.set_cdata("cdata_token") # solver.set_chlpagedata("chlpagedata_token") solver.set_soft_id(0) token = solver.solve_and_return_solution() if token != 0: print("token: " + token) print("user-agent: " + solver.get_user_agent()) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Error-handling example for turnstileProxyon Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/turnstile.md Configures the solver with proxy type and credentials, then handles failure by printing error_code and err_string. ```python solver = turnstileProxyon() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_type("http") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### Example usage of amazonProxyon Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/amazon.md Shows how to instantiate amazonProxyon, set required parameters (API key, website URL, website key, IV, context, proxy), and solve the captcha. The token is printed on success; otherwise, the error code is printed. ```python from anticaptchaofficial.amazonproxyon import * solver = amazonProxyon() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("waf key") solver.set_iv("iv value") solver.set_context("context value") solver.set_proxy_type("http") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) token = solver.solve_and_return_solution() if token != 0: print("token: " + token) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Basic example from antibot_example.py Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antibotcookietask.md Shows how to solve an anti-bot task, extract cookies and fingerprint, and use them with a requests session. Requires a proxy. On failure, prints 'could not solve task' and exits. ```python from anticaptchaofficial.antibotcookietask import * import requests solver = antibotcookieTask() solver.set_verbose(1) solver.set_key("API_KEY_HERE") solver.set_website_url("https://www.somewebsite.com/") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) solver.set_proxy_login("login") solver.set_proxy_password("password") solver.set_soft_id(0) result = solver.solve_and_return_solution() if result == 0: print("could not solve task") exit() print(result) cookies, localStorage, fingerprint = result["cookies"], result["localStorage"], result["fingerprint"] if len(cookies) == 0: print("empty cookies, try again") exit() cookie_string = '; '.join([f'{key}={value}' for key, value in cookies.items()]) user_agent = fingerprint['self.navigator.userAgent'] print(f"use these cookies for requests: {cookie_string}") print(f"use this user-agent for requests: {user_agent}") s = requests.Session() proxies = { "http": "http://login:password@1.2.3.4:3128", "https": "http://login:password@1.2.3.4:3128" } s.proxies = proxies content = s.get("https://www.somewebsite.com/", headers={ "Cookie": cookie_string, "User-Agent": user_agent }).text print(content) ``` -------------------------------- ### GeeTest v4 example with error handling Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/geetest.md Example usage for solving a GeeTest v4 captcha using geetestProxyless. It sets the captchaId as the gt key, version 4, and initParameters with riskType slide, then handles failure by printing error_code and err_string. ```python from anticaptchaofficial.geetestproxyless import * solver = geetestProxyless() solver.set_verbose(1) solver.set_key("YOUR_API_KEY") solver.set_website_url("https://address.com") solver.set_gt_key("captchaId value") # v4 uses the captchaId solver.set_version(4) solver.set_init_parameters({"riskType": "slide"}) token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("result tokens: ", token) ``` -------------------------------- ### geetestProxyon error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/geetest.md Shows how to handle failure by checking if the token is 0 and printing the error code and error string. It sets proxy type to http and uses a different proxy address and port. ```python solver = geetestProxyon() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://address.com") solver.set_gt_key("CONSTANT_GT_KEY") solver.set_challenge_key("VARIABLE_CHALLENGE_KEY") solver.set_proxy_type("http") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("result tokens:", token) ``` -------------------------------- ### Altcha solver usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/altcha.md Shows how to use altchaProxyless to solve an Altcha challenge. Set the key, website URL, and either challenge URL or challenge JSON, then call solve_and_return_solution. On success, prints the token and user-agent; on failure, prints the error code. ```python from anticaptchaofficial.altchaproxyless import * solver = altchaProxyless() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") # Option 1: set challenge URL solver.set_challenge_url("/path/to/challenge/url") # Option 2: set challenge JSON grabbed from challenge URL # solver.set_challenge_json('{"algorithm":"SHA-256","challenge":"2a40f7ba...","salt":"08d7f273...","signature":"1de2bbf2..."}') solver.set_soft_id(0) token = solver.solve_and_return_solution() if token != 0: print("token: " + token) print("user-agent: " + solver.get_user_agent()) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/funcaptcha.md Shows how to handle failures when solving a FunCaptcha with proxy. Sets proxy type to http and uses error_code and err_string for diagnostics. ```python solver = funcaptchaProxyon() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX") solver.set_proxy_type("http") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### Altcha error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/altcha.md Shows how to handle errors when solving an Altcha challenge. Sets the challenge JSON directly and checks the return value of solve_and_return_solution. On failure, prints the error code and error string. ```python solver = altchaProxyless() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_challenge_json('{"algorithm":"SHA-256","challenge":"...","salt":"...","signature":"..."}') token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### friendlyCaptchaProxyon error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/friendlycaptcha.md Shows how to handle errors when using friendlyCaptchaProxyon. It sets proxy type, address, and port, then checks if the token is 0 and prints the error code and string. ```python solver = friendlyCaptchaProxyon() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_type("http") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### friendlyCaptchaProxyless error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/friendlycaptcha.md Shows how to handle errors when using friendlyCaptchaProxyless. It checks if the token is 0 and prints the error code and string. ```python solver = friendlyCaptchaProxyless() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### Basic image captcha solving example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/imagecaptcha.md Shows the minimal usage: create an imagecaptcha solver, set verbose, key, and optional soft_id, then call solve_and_return_solution with a file path. On success prints the captcha text; on failure prints the error code. ```python from anticaptchaofficial.imagecaptcha import * solver = imagecaptcha() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_soft_id(0) # optional, developer commission id captcha_text = solver.solve_and_return_solution("captcha.jpeg") if captcha_text != 0: print("captcha text " + captcha_text) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### friendlyCaptchaProxyon usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/friendlycaptcha.md Shows how to use friendlyCaptchaProxyon to solve a Friendly Captcha with a proxy. It sets API key, website URL, website key, proxy address, port, login, and password, then prints the token or error. ```python from anticaptchaofficial.friendlycaptchaproxyon import * solver = friendlyCaptchaProxyon() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) solver.set_proxy_login("login") solver.set_proxy_password("password") token = solver.solve_and_return_solution() if token != 0: print("token: " + token) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Error-handling example for recaptchaV2Proxyon Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav2.md Shows how to handle failure by checking the return value and printing error_code and err_string, plus retrieving the user agent on success. ```python solver = recaptchaV2Proxyon() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_type("http") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) g_response = solver.solve_and_return_solution() if g_response == 0: print("failed:", solver.error_code) print("details:", solver.err_string) else: print("g-response:", g_response) print("user-agent:", solver.get_user_agent()) ``` -------------------------------- ### Basic example for recaptchaV2Proxyless Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav2.md Shows how to set up and solve a reCAPTCHA v2 challenge using recaptchaV2Proxyless. Includes setting verbose mode, API key, website URL, website key, and optional invisible mode, then prints the g-response and user-agent on success or the error code on failure. ```python from anticaptchaofficial.recaptchav2proxyless import * solver = recaptchaV2Proxyless() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") # only for V2-invisible recaptcha: solver.set_is_invisible(1) solver.set_soft_id(0) g_response = solver.solve_and_return_solution() if g_response != 0: print("g-response: " + g_response) print("user-agent: " + solver.get_user_agent()) else: print("task finished with error " + solver.error_code) ``` -------------------------------- ### Error-handling example for recaptchaV3Proxyless Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav3.md Shows error handling when solve_and_return_solution returns 0, and demonstrates that invalid min_score values fall back to 0.9. ```python solver = recaptchaV3Proxyless() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_min_score(0.7) # invalid values fall back to 0.9 g_response = solver.solve_and_return_solution() if g_response == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("g-response:", g_response) ``` -------------------------------- ### hCaptchaProxyon error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/hcaptcha.md Shows how to handle failure by checking the returned token. If token equals 0, prints the error code and error string; otherwise prints the token and respkey. ```python solver = hCaptchaProxyon() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) solver.set_proxy_login("login") solver.set_proxy_password("password") token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token, "| respkey:", solver.get_respkey()) ``` -------------------------------- ### Turnstile error-handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/turnstile.md Demonstrates error handling when solving a Turnstile task. If the token is 0, prints the error code and error string; otherwise prints the token. ```python solver = turnstileProxyless() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_action("login") solver.set_cdata("cdata_token") token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### Reporting methods usage example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antinetworking.md Shows how to report incorrect or correct recaptcha solutions after solving. The report_incorrect_recaptcha call is used when the token is rejected, and report_correct_recaptcha optionally rewards good solving quality. ```python solver = recaptchaV2Proxyless() # ... solve ... solver.report_incorrect_recaptcha() # previously solved token was rejected by target site solver.report_correct_recaptcha() # optionally reward good solving quality ``` -------------------------------- ### Error handling example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antibotcookietask.md Shows how to handle failure by checking result == 0 and printing error_code and err_string. Uses proxy type 'http'. ```python from anticaptchaofficial.antibotcookietask import antibotcookieTask solver = antibotcookieTask() solver.set_key("API_KEY_HERE") solver.set_website_url("https://www.somewebsite.com/") solver.set_proxy_type("http") solver.set_proxy_address("1.2.3.4") solver.set_proxy_port(3128) result = solver.solve_and_return_solution() if result == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("cookies:", result.get("cookies")) print("fingerprint:", result.get("fingerprint")) ``` -------------------------------- ### Example 2 — standalone widget mode + error handling Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/amazon.md Solves a standalone Amazon WAF widget triggered by user action. Requires set_waf_type("widget") and set_jsapi_script. Prints the error code and string on failure, or the token on success. ```python from anticaptchaofficial.amazonproxyless import * solver = amazonProxyless() solver.set_key("YOUR_API_KEY") solver.set_website_url("https://website.com") solver.set_website_key("Captcha widget's API key from AwsWafCaptcha.renderCaptcha function") solver.set_waf_type("widget") solver.set_jsapi_script("https://...jsapi.js") token = solver.solve_and_return_solution() if token == 0: print("failed:", solver.error_code, "-", solver.err_string) else: print("token:", token) ``` -------------------------------- ### Error handling and reporting example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav2.md Shows how to handle errors and report the solved token back to the service. Exits with SystemExit(1) on failure, and uses report_incorrect_recaptcha() or report_correct_recaptcha() to report the token's acceptance. ```python solver = recaptchaV2Proxyless() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") g_response = solver.solve_and_return_solution() if g_response == 0: print("failed:", solver.error_code, "-", solver.err_string) raise SystemExit(1) # report the solved token back to the service solver.report_incorrect_recaptcha() # token was rejected by the site # solver.report_correct_recaptcha() # token was accepted (improves quality) ``` -------------------------------- ### recaptchaV2EnterpriseProxyless error handling + payload example Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/recaptchav2enterprise.md Demonstrates setting an enterprise payload and invisible mode, then handling errors via error_code and err_string. ```APIDOC ## [METHOD] solve_and_return_solution (with payload and invisible) ### Description Demonstrates setting an enterprise payload and invisible mode, then handling errors via error_code and err_string. ### Method solve_and_return_solution ### Endpoint recaptchaV2EnterpriseProxyless.solve_and_return_solution() ### Parameters #### Path Parameters - *(none)* - All inputs come from configured attributes ### Request Example ```python solver = recaptchaV2EnterpriseProxyless() solver.set_key("YOUR_KEY") solver.set_website_url("https://website.com") solver.set_website_key("SITE_KEY") solver.set_enterprise_payload({"s": "sometoken", "action": "form_submit"}) solver.set_is_invisible(True) # for enterprise invisible captchas g_response = solver.solve_and_return_solution() ``` ### Response #### Success Response (200) - **gRecaptchaResponse** (str) - The solution token #### Response Example ```python if g_response == 0: print("failed:", solver.error_code, "-", solver.err_string) raise SystemExit(1) print("g-response:", g_response) ``` ``` -------------------------------- ### Get object coordinates in an image Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/README.md Solves an ImageCoordinatesTask to get object coordinates in an image. Requires an image file path. The solution returns coordinates; if it fails, the error code is printed. ```python from anticaptchaofficial.imagetocoordinates import * solver = imagetocoordinates() solver.set_verbose(1) solver.set_key("YOUR_KEY") solver.set_mode("points") solver.set_comment("Select in specified order") # Specify softId to earn 10% commission with your app. # Get your softId here: https://anti-captcha.com/clients/tools/devcenter solver.set_soft_id(0) coordinates = solver.solve_and_return_solution("coordinates.png") if coordinates != 0: print("coordinates: ", captcha_text) else: print("task finished with error "+solver.error_code) ``` -------------------------------- ### Module graph of anticaptchaofficial package Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/index.md Directory tree showing all solver modules and their corresponding task types. The entry point __init__.py only creates a session and default_headers without re-exporting solver classes. Each solver module begins with 'from anticaptchaofficial.antinetworking import *', which also imports module names like time, json, requests, and urllib3 into the solver namespace. ```text anticaptchaofficial/ ├── __init__.py # creates session + default_headers (no exports) ├── antinetworking.py # antiNetworking base class, session, default_headers ├── imagecaptcha.py # imagecaptcha -> ImageToTextTask ├── imagetocoordinates.py # imagetocoordinates -> ImageToCoordinatesTask ├── recaptchav2proxyless.py # recaptchaV2Proxyless -> RecaptchaV2TaskProxyless ├── recaptchav2proxyon.py # recaptchaV2Proxyon -> RecaptchaV2Task ├── recaptchav2enterpriseproxyless.py # recaptchaV2EnterpriseProxyless -> RecaptchaV2EnterpriseTaskProxyless ├── recaptchav2enterpriseproxyon.py # recaptchaV2EnterpriseProxyon -> RecaptchaV2EnterpriseTask ├── recaptchav3proxyless.py # recaptchaV3Proxyless -> RecaptchaV3TaskProxyless ├── recaptchav3enterpriseproxyless.py # recaptchaV3EnterpriseProxyless -> RecaptchaV3TaskProxyless (isEnterprise) ├── hcaptchaproxyless.py # hCaptchaProxyless -> HCaptchaTaskProxyless ├── hcaptchaproxyon.py # hCaptchaProxyon -> HCaptchaTask ├── funcaptchaproxyless.py # funcaptchaProxyless -> FunCaptchaTaskProxyless ├── funcaptchaproxyon.py # funcaptchaProxyon -> FunCaptchaTask ├── geetestproxyless.py # geetestProxyless -> GeeTestTaskProxyless ├── geetestproxyon.py # geetestProxyon -> GeeTestTask ├── turnstileproxyless.py # turnstileProxyless -> TurnstileTaskProxyless ├── turnstileproxyon.py # turnstileProxyon -> TurnstileTask ├── antigatetask.py # antigateTask -> AntiGateTask ├── antibotcookietask.py # antibotcookieTask -> AntiBotCookieTask ├── prosopoproxyless.py # prosopoProxyless -> ProsopoTaskProxyless ├── prosopoproxyon.py # prosopoProxyon -> ProsopoTask ├── friendlycaptchaproxyless.py # friendlyCaptchaProxyless -> FriendlyCaptchaTaskProxyless ├── friendlycaptchaproxyon.py # friendlyCaptchaProxyon -> FriendlyCaptchaTask ├── amazonproxyless.py # amazonProxyless -> AmazonTaskProxyless ├── amazonproxyon.py # amazonProxyon -> AmazonTask ├── altchaproxyless.py # altchaProxyless -> AltchaTaskProxyless └── altchaproxyon.py # altchaProxyon -> AltchaTask ``` -------------------------------- ### set_poolSize method signature Source: https://github.com/anti-captcha/anticaptcha-python/blob/master/_autodocs/api-reference/antinetworking.md Mounts a new requests.adapters.HTTPAdapter on the shared module session for https://, replacing the default adapter. Returns None. ```python def set_poolSize(self, pool_connections, pool_maxsize=100): ```