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

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