예제 #1
0
        /// <summary>
        /// Image captcha
        /// </summary>
        static void test_image()
        {
            // account balance
            string balance = bcs.account_balance();

            Console.WriteLine(string.Format("Balance: {0}", balance));

            Console.WriteLine("Solving image captcha ...");
            var d = new Dictionary <string, string>();

            d.Add("image", "captcha.jpg");
            // d.Add("is_case", "true");       // case sensitive, default: false, optional
            // d.Add("is_phrase", "true");     // contains at least one space, default: false, optional
            // d.Add("is_math", "true");       // math calculation captcha, default: false, optional
            // d.Add("alphanumeric", "2");     // 1 (digits only) or 2 (letters only), default: all characters
            // d.Add("minlength", "3");        // minimum length of captcha text, default: any
            // d.Add("maxlength", "4");        // maximum length of captcha text, default: any
            // d.Add("affiliate_id", "get it from /account");      // affiliate ID
            var    id         = bcs.submit_image_captcha(d);
            string image_text = "";

            while (image_text == "")
            {
                image_text = bcs.retrieve(id)["text"];
                Thread.Sleep(5000);
            }
            Console.WriteLine(string.Format("Captcha text: {0}", image_text));
            // bcs.set_captcha_bad(id);      // set captcha as bad
        }
        public static string SolverCaptcha(string imageBase64, string acess_token)
        {
            BestCaptchaSolverAPI        bcs = new BestCaptchaSolverAPI(acess_token);
            Dictionary <string, string> d   = new Dictionary <string, string>()
            {
                { "image", imageBase64 }
            };
            string taskId = bcs.submit_image_captcha(d);
            Dictionary <string, string> apiResponse = bcs.retrieve(taskId);

            apiResponse.TryGetValue("text", out string captchaResultText);
            return(captchaResultText);
        }
예제 #3
0
        /// <summary>
        /// Image captcha automation with browser
        /// </summary>
        private void browser_image()
        {
            Console.WriteLine("[+] Image (classic) captcha automation with browser");
            Console.WriteLine("---------------------------------");
            Console.WriteLine("[+] Starting browser");
            string url = "https://bestcaptchasolver.com/automation/image";

            using (var b = new ChromeDriver())
            {
                Console.WriteLine("[+] Navigating to image captcha page");
                b.Navigate().GoToUrl(url);
                Console.WriteLine("[+] Completing fields of form");
                b.FindElementById("username").SendKeys("image-browser-user-123");
                string captcha_image_b64 = b.FindElementById("automation-container").FindElement(By.ClassName("img-responsive")).GetAttribute("src");
                Console.WriteLine("[+] Submitting image to bestcaptchasolver");
                var opts = new Dictionary <string, string>();
                opts.Add("image", captcha_image_b64);

                // submit to bcs for solving
                var id = bcs.submit_image_captcha(opts);
                Console.WriteLine(string.Format("[+] Got ID {0}, waiting for completion...", id));
                string text = "";
                while (text == "")
                {
                    text = bcs.retrieve(id)["text"];
                    if (text != "")
                    {
                        break;                    // get out if not null
                    }
                    Thread.Sleep(5000);
                }
                Console.WriteLine(string.Format("[+] Response from bestcaptchasolver.com: {0}", text));
                b.FindElementById("captcha-text").SendKeys(text);     // write text received from bcs
                Console.WriteLine("[+] Submitting form");
                b.FindElementById("automation_submit").Click();       // submit form
                Console.WriteLine("[+] Form submitted !");
                Thread.Sleep(SLEEP * 1000);
            }
        }