ich bin grade dabei ein Image Captcha zu lösen, bin auch zu 98% fertisch. Hab nur ein kleines Problemchen.
Ich muss die Captcha Antwort für sich rauslesen und einfügen (W9h5k)
Webseite wo der Captcha ist:

github Code vom Captcha Solver (Beispiel Code):

Mein Code:
Code:
using System;
using OpenQA.Selenium.Chrome;
using ImageTypers;
using OpenQA.Selenium;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
namespace Test_Selenium
{
class Program
{
static void Main(string[] args)
{
// Chrome Optionen festlegen
ChromeOptions option = new ChromeOptions();
//option.AddArgument("--headless");
option.AddArguments("ignore-certificate-errors");
// Chrome Service festlegen
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
ChromeDriver WebDriver = new ChromeDriver(service, option);
try
{
WebDriver.Navigate().GoToUrl("https://2captcha.com/demo/normal"); // go to normal test page
// get access token from: http://www.imagetyperz.com
string token = "XXXX";
ImageTypersAPI i = new ImageTypersAPI(token);
// balance
string balance = i.account_balance();
Console.WriteLine(string.Format("Balance: {0}", balance));
// optional parameters dict
Dictionary<string, string> image_params = new Dictionary<string, string>();
image_params.Add("iscase", "true"); // case sensitive captcha
//image_params.Add("isphrase", "true"); // text contains at least one space (phrase)
//image_params.Add("ismath", "true"); // instructs worker that a math captcha has to be solved
//image_params.Add("alphanumeric", "1"); // 1 - digits only, 2 - letters only
image_params.Add("minlength", "2"); // captcha text length (minimum)
image_params.Add("maxlength", "5"); // captcha text length (maximum)
Console.WriteLine("Waiting for captcha to be solved...");
string captcha_id = i.submit_image("https://2captcha.com/template/demo/images/normal.jpg", image_params);
Dictionary<string, string> response = i.retrieve_response(captcha_id);
ImageTypers.Utils.print_response(response);
var array = response.ToArray();
var first = array[1];
Console.WriteLine(first);
//WebDriver.FindElementByXPath("/html/body/div[1]/div[2]/div/div/div/div[1]/div/div/div/div/div/div[2]/div/form/input").SendKeys(response);
}
finally
{
Console.WriteLine("Fertig");
Console.ReadLine();
WebDriver.Quit();
}
}
}
}
Code:
Balance: $15.2308 Waiting for captcha to be solved... Response -------------------------------- "CaptchaId" - "15842269" "Response" - "w9h5k" "Cookie_OutPut" - "" "Proxy_reason" - "" "Recaptcha score" - "0.00" "Status" - "Solved" -------------------------------- [Response, w9h5k] Fertig






