Page tree
Skip to end of metadata
Go to start of metadata

At the moment the following language examples are available:


 PHP example

Download : Git Repository
Google No-Captcha solving example
include("anticaptcha.php");
include("nocaptcha.php");

$api = new NoCaptcha();
$api->setVerboseMode(true);
        
//your anti-captcha.com account key
$api->setKey("12345678901234567890123456789012");

//recaptcha key from target website
$api->setWebsiteURL("http://http.myjino.ru/recaptcha/test-get.php");
$api->setWebsiteKey("6Lc_aCMTAAAAABx7u2W0WPXnVbI_v6ZdbM6rYf16");

//proxy access parameters
$api->setProxyType("http");
$api->setProxyAddress("2a01:2f8:121:11c6::2");
$api->setProxyPort(9191);
$api->setProxyLogin("thelogin");
$api->setProxyPassword("thepassword");

//browser header parameters
$api->setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116");

if (!$api->createTask()) {
    $api->debout("API v2 send failed - ".$api->getErrorMessage(), "red");
    return false;
}

$taskId = $api->getTaskId();


if (!$api->waitForResult()) {
    $api->debout("could not solve captcha", "red");
    $api->debout($api->getErrorMessage());
} else {
    echo "\nhash result: ".$api->getTaskSolution()."\n\n";
}

 NodeJS example

Download: Git Repository
Anti-Captcha NodeJS example
// http module should be installed:
// npm i http

// Params:
// your anti-captcha.com account key
var anticaptcha = require('./anticaptcha')('12345678901234567890123456789012');

//recaptcha key from target website
anticaptcha.setWebsiteURL("http://http.myjino.ru/recaptcha/test-get.php");
anticaptcha.setWebsiteKey("6Lc_aCMTAAAAABx7u2W0WPXnVbI_v6ZdbM6rYf16");

//proxy access parameters
anticaptcha.setProxyType("http");
anticaptcha.setProxyAddress("proxyaddress");
anticaptcha.setProxyPort(8080);
anticaptcha.setProxyLogin("proxylogin");
anticaptcha.setProxyPassword("proxypassword");

//browser header parameters
anticaptcha.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116");

anticaptcha.createTask(function (err, taskId) {
    if (err) {
        console.error(err);
        return;
    }

    console.log(taskId);

    anticaptcha.getTaskSolution(taskId, function (err, taskSolution) {
        if (err) {
            console.error(err);
            return;
        }

        console.log(taskSolution);
    });
});

 JAVA example

Download : Git Repository
import java.io.IOException;

public class Main {

    private static String host = "api.anti-captcha.com";
    private static String clientKey = "12345678901234567890123456789012";

    public static void main(String[] args) throws InterruptedException, IOException {

        AnticaptchaTask task1 = AnticaptchaApiWrapper.createNoCaptchaTask(
                host,
                clientKey,
                "http://http.myjino.ru/recaptcha/test-get.php",	//target website
                "6Lc_aCMTAAAAABx7u2W0WPXnVbI_v6ZdbM6rYf16",		//target website Recaptcha key
                AnticaptchaApiWrapper.ProxyType.http,
                "xx.xx.xx.xxx",									//ipv4 or ipv6 proxy address
                8080,											//proxy port
                "login",										//proxy login
                "password",										//proxy password
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
        );

        System.out.println("NoCaptcha task is sent, will wait for the result.");
        Thread.sleep(10_000);
        processTask(task1);


        // Exit
        System.in.read();
    }

    private static String processTask(AnticaptchaTask task) throws InterruptedException {

        AnticaptchaResult response;

        do
        {
            response = AnticaptchaApiWrapper.getTaskResult(host, clientKey, task);

            if (response.getStatus().equals(AnticaptchaResult.Status.ready))
            {
                break;
            }

            System.out.println("Not done yet, waiting...");
            Thread.sleep(1000);
        } while (response != null && response.getStatus().equals(AnticaptchaResult.Status.processing));

        if (response == null || response.getSolution() == null) {
            System.out.println("Unknown error occurred...");
            System.out.println("Response dump:");
            System.out.println(response);
        } else {
            System.out.println("The answer is '" + response.getSolution() + "'");
        }

        return response.getSolution();
    }
}

 C# example

Download: Git repository
using System;
using System.Threading;

namespace Anticaptcha_example
{
    internal class Program
    {
        private const string Host = "api.anti-captcha.com";
        private const string ClientKey = "12345678901234567890123456789012";

        private static void Main(string[] args)
        {
            var task1 = AnticaptchaApiWrapper.CreateNoCaptchaTask(
                Host,
                ClientKey,
                "http://http.myjino.ru/recaptcha/test-get.php",		//target website address
                "6Lc_aCMTAAAAABx7u2W0WPXnVbI_v6ZdbM6rYf16",			//target website Recaptcha key
                AnticaptchaApiWrapper.ProxyType.http,					
                "xx.xx.xx.xxx",										//ipv4 or ipv6 proxy address
                8080,												//proxy port
                "login",											//proxy login				
                "password",											//proxy password
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
                );


            Console.WriteLine("NoCaptcha task is sent, will wait for the result.");
            Thread.Sleep(10000);
            ProcessTask(task1);


            // Exit
            Console.ReadKey();
        }

        private static String ProcessTask(AnticaptchaTask task)
        {
            AnticaptchaResult response;

            do
            {
                response = AnticaptchaApiWrapper.GetTaskResult(Host, ClientKey, task);

                if (response.GetStatus().Equals(AnticaptchaResult.Status.ready))
                {
                    break;
                }

                Console.WriteLine("Not done yet, waiting...");
                Thread.Sleep(1000);
            } while (response != null && response.GetStatus().Equals(AnticaptchaResult.Status.processing));

            if (response == null || response.GetSolution() == null)
            {
                Console.WriteLine("Unknown error occurred...");
                Console.WriteLine("Response dump:");
                Console.WriteLine(response);
            }
            else
            {
                Console.WriteLine("The answer is '" + response.GetSolution() + "'");
            }

            return response.GetSolution();
        }
    }
}

  • No labels