Esempio n. 1
0
        static void Main(string[] args)
        {
            AntiCaptchaApi         AntiCaptchaApi = new AntiCaptchaApi("https://api.anti-captcha.com", "Client Key");
            NoCaptchaTaskProxyless captchaTask    = new NoCaptchaTaskProxyless("Website Url", "Website Key");

            System.Threading.Tasks.Task.Run(async() =>
            {
                // Get balance
                BalanceResponse balanceResponse = await AntiCaptchaApi.GetBalanceAsync();
                float balance = balanceResponse.Balance;

                // Make a task
                TaskResponse response = await AntiCaptchaApi.CreateTaskAsync(captchaTask);
                int taskId            = response.TaskId;

                // Get the task result
                TaskResult <NoCaptchaSolution> taskResult = null;
                do
                {
                    try
                    {
                        taskResult = await AntiCaptchaApi.GetTaskResultAsync <NoCaptchaSolution>(taskId);
                        // Wait 0.5 seconds before requesting again
                        System.Threading.Tasks.Task.Delay(500).Wait();
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }while (taskResult != null && taskResult.Status != "ready");
            });

            Console.Read();
        }
Esempio n. 2
0
        public ResolveState ResoloveCaptcha()
        {
            ResolveState resolveState;
            var          client = new CapMonsterClient(captchaStatics.Apikey);

            try
            {
                var captchaTask = new NoCaptchaTaskProxyless
                {
                    WebsiteUrl = YolikerStatics.LikeCustomUri,
                    WebsiteKey = YolikerStatics.GooglePublicKey,
                };
                var taskId            = client.CreateTaskAsync(captchaTask).Result;
                var solution          = client.GetTaskResultAsync <NoCaptchaTaskProxylessResult>(taskId).Result;
                var recaptchaResponse = solution.GRecaptchaResponse;
                captchaStatics.SolvedCaptchaResponse = recaptchaResponse;
                resolveState = ResolveState.SUCCESS;
            }
            catch
            {
                resolveState = ResolveState.ERROR;
            }
            finally
            {
                client.Dispose();
            }
            return(resolveState);
        }
Esempio n. 3
0
        private static async Task TestRecaptchaAsync()
        {
            var captchaTask = new NoCaptchaTaskProxyless
            {
                WebsiteUrl = "URL",
                WebsiteKey = "KEY",
                UserAgent  = "USER_AGENT"
            };

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            int taskId;

            try
            {
                taskId = await client.CreateTaskAsync(captchaTask);
            }
            catch (CapMonsterException e)
            {
                Console.WriteLine($"{e.ErrorCode}: {e.ErrorDescription}");
                return;
            }

            try
            {
                var solution = await client.GetTaskResultAsync <NoCaptchaTaskProxylessResult>(taskId);

                stopwatch.Stop();
                Console.WriteLine($"Solved in {stopwatch.ElapsedMilliseconds}ms.");
            }
            catch (CapMonsterException e)
            {
                Console.WriteLine($"{e.ErrorCode}: {e.ErrorDescription}");
                return;
            }
        }
Esempio n. 4
0
        public override async Task <string> GetCaptchaResponse(string siteKey, string url)
        {
            AntiCaptcha            client = new AntiCaptcha(_apiKey);
            NoCaptchaTaskProxyless task   = new NoCaptchaTaskProxyless
            {
                websiteKey = siteKey,
                websiteURL = url
            };
            TaskResponse response = await client.SubmitTask(task);

            while (true)
            {
                NoCaptchaSolution solution = await client.GetNoCaptchaSolution(response.taskId);

                if (solution.errorId != 0)
                {
                    return("");
                }
                if (solution.status == "ready")
                {
                    return(solution.solution.gRecaptchaResponse);
                }
            }
        }