diff --git a/AntiCaptcha.Sandbox/Program.cs b/AntiCaptcha.Sandbox/Program.cs index c6bf661..94cb030 100644 --- a/AntiCaptcha.Sandbox/Program.cs +++ b/AntiCaptcha.Sandbox/Program.cs @@ -13,28 +13,75 @@ static void Main(string[] args) static async Task Foo() { - var captcha = new AntiCaptcha(" ## YOUR API KEY ## "); - // .. additionally you can pass your own httpClient class - var captchaWithHttpClient = new AntiCaptcha(" ## YOUR API KEY ## ", new HttpClient()); + /* + * Class initialization + * Optionally you can pass 2nd parameter `httpClient` with custom HttpClient to use while requesting API + */ + var captcha = new AntiCaptcha("API_KEY"); + var captchaCustomHttp = new AntiCaptcha("API_KEY", new HttpClient()); - // Get current balance + /* + * Get current balance + */ var balance = await captcha.GetBalance(); - // Solve image captcha - var image = await captcha.SolveImage("iVBORw0KGgo..."); + /* + * Type: Image + * + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/image + */ + var image = await captcha.SolveImage("BASE64_IMAGE"); - // Solve ReCaptchaV2 - var recaptcha = await captcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com"); - var recaptchaInvisible = await captcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com", true); + /* + * Type: ReCaptcha V2 + * Optionally you can pass 3rd parameter `isInvisible` to indicate if the reCaptcha is setup as invisible + * + * Homepage: https://www.google.com/recaptcha/ + * Documentation (vendor): https://developers.google.com/recaptcha/docs/display + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/recaptcha + */ + var reCaptcha = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL"); + var reCaptchaInvisible = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL", true); + + /* + * Type: ReCaptcha V3 + * If you get ERROR_INCORRECT_SESSION_DATA error you may need to increase minScore value + * + * Homepage: https://www.google.com/recaptcha/ + * Documentation (vendor): https://developers.google.com/recaptcha/docs/v3 + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/recaptcha + */ + var reCaptchaV3 = await captcha.SolveReCaptchaV3("SITE_KEY", "https://WEBSITE_URL", 0.9, "SOME_ACTION"); + + /* + * Type: hCaptcha + * + * Homepage: https://www.hcaptcha.com/ + * Documentation (vendor): https://docs.hcaptcha.com/ + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/hcaptcha + */ + var hCaptcha = await captcha.SolveHCaptcha("SITE_KEY", "https://WEBSITE_URL"); - // Solve FunCaptcha - var fun = await captcha.SolveFunCaptcha("FUN_CAPTCHA_PUBLIC_KEY", "https://example.com"); + /* + * Type: GeeTest + * + * Homepage: https://www.geetest.com/en + * Documentation (vendor): https://docs.geetest.com/en + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/geetest + */ + var geeTest = await captcha.SolveGeeTest("SITE_KEY", "https://WEBSITE_URL", "CHALLENGE"); - // Solve SquareNet - var square = await captcha.SolveSquareNet("iVBORw0KGgo...", "banana", 3, 3); + /* + * Type: FunCaptcha + * + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/funcaptcha + */ + var funCaptcha = await captcha.SolveFunCaptcha("SITE_KEY", "https://WEBSITE_URL"); - // Solve GeeTest - var gee = await captcha.SolveGeeTest("GEE_TEST_KEY", "https://example.com", "CHALLENGE"); + /* + * Type: SquareNet + */ + var squareNet = await captcha.SolveSquareNet("BASE64_IMAGE", "OBJECT_NAME", 3, 3); Debugger.Break(); } diff --git a/AntiCaptcha/AntiCaptcha.cs b/AntiCaptcha/AntiCaptcha.cs index ff9d8d2..60e1d06 100644 --- a/AntiCaptcha/AntiCaptcha.cs +++ b/AntiCaptcha/AntiCaptcha.cs @@ -157,6 +157,46 @@ public async Task SolveReCaptchaV2(string googleSiteKey, stri return new AntiCaptchaResult(true, result.Dictionary["gRecaptchaResponse"].ToString()); } + public async Task SolveReCaptchaV3(string googleSiteKey, string pageUrl, double minScore, string pageAction, CancellationToken cancellationToken = default) + { + var result = await Solve(5, new Dictionary + { + {"task", new Dictionary + { + {"type", "RecaptchaV3TaskProxyless"}, + {"websiteURL", pageUrl}, + {"websiteKey", googleSiteKey}, + {"minScore", minScore}, + {"pageAction", pageAction}, + } + } + }, cancellationToken).ConfigureAwait(false); + + if (!result.Success) + return new AntiCaptchaResult(false, result.Response); + + return new AntiCaptchaResult(true, result.Dictionary["gRecaptchaResponse"].ToString()); + } + + public async Task SolveHCaptcha(string siteKey, string pageUrl, CancellationToken cancellationToken = default) + { + var result = await Solve(10, new Dictionary + { + {"task", new Dictionary + { + {"type", "HCaptchaTaskProxyless"}, + {"websiteURL", pageUrl}, + {"websiteKey", siteKey}, + } + } + }, cancellationToken).ConfigureAwait(false); + + if (!result.Success) + return new AntiCaptchaResult(false, result.Response); + + return new AntiCaptchaResult(true, result.Dictionary["gRecaptchaResponse"].ToString()); + } + public async Task SolveFunCaptcha(string funCaptchaPublicKey, string pageUrl, CancellationToken cancellationToken = default) { var result = await Solve(10, new Dictionary diff --git a/AntiCaptcha/AntiCaptcha.csproj b/AntiCaptcha/AntiCaptcha.csproj index 1f25da0..d0dd8e5 100644 --- a/AntiCaptcha/AntiCaptcha.csproj +++ b/AntiCaptcha/AntiCaptcha.csproj @@ -9,12 +9,12 @@ https://github.com/Zaczero/AntiCaptcha - 1.2 - anticaptcha, captcha, solver, recaptcha, google, text, image, wrapper, api + 1.3 + anticaptcha, captcha, solver, google, recaptcha, hcaptcha, geetest, text, image, wrapper, api AntiCaptchaAPI true - 1.2.0.0 - 1.2.0.0 + 1.3.0.0 + 1.3.0.0 MIT https://github.com/Zaczero/AntiCaptcha AntiCaptcha.png diff --git a/README.md b/README.md index d1d15ba..3df93d8 100644 --- a/README.md +++ b/README.md @@ -22,28 +22,75 @@ An online captcha solving and image recognition service. ### Sample code ```cs -var captcha = new AntiCaptcha(" ## YOUR API KEY ## "); -// .. additionally you can pass your own httpClient class -var captchaWithHttpClient = new AntiCaptcha(" ## YOUR API KEY ## ", new HttpClient()); - -// Get current balance +/* + * Class initialization + * Optionally you can pass 2nd parameter `httpClient` with custom HttpClient to use while requesting API + */ +var captcha = new AntiCaptcha("API_KEY"); +var captchaCustomHttp = new AntiCaptcha("API_KEY", new HttpClient()); + +/* + * Get current balance + */ var balance = await captcha.GetBalance(); -// Solve image captcha -var image = await captcha.SolveImage("iVBORw0KGgo..."); - -// Solve ReCaptchaV2 -var recaptcha = await captcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com"); -var recaptchaInvisible = await captcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com", true); - -// Solve FunCaptcha -var fun = await captcha.SolveFunCaptcha("FUN_CAPTCHA_PUBLIC_KEY", "https://example.com"); - -// Solve SquareNet -var square = await captcha.SolveSquareNet("iVBORw0KGgo...", "banana", 3, 3); - -// Solve GeeTest -var gee = await captcha.SolveGeeTest("GEE_TEST_KEY", "https://example.com", "CHALLENGE"); +/* + * Type: Image + * + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/image + */ +var image = await captcha.SolveImage("BASE64_IMAGE"); + +/* + * Type: ReCaptcha V2 + * Optionally you can pass 3rd parameter `isInvisible` to indicate if the reCaptcha is setup as invisible + * + * Homepage: https://www.google.com/recaptcha/ + * Documentation (vendor): https://developers.google.com/recaptcha/docs/display + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/recaptcha + */ +var reCaptcha = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL"); +var reCaptchaInvisible = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL", true); + +/* + * Type: ReCaptcha V3 + * If you get ERROR_INCORRECT_SESSION_DATA error you may need to increase minScore value + * + * Homepage: https://www.google.com/recaptcha/ + * Documentation (vendor): https://developers.google.com/recaptcha/docs/v3 + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/recaptcha + */ +var reCaptchaV3 = await captcha.SolveReCaptchaV3("SITE_KEY", "https://WEBSITE_URL", 0.9, "SOME_ACTION"); + +/* + * Type: hCaptcha + * + * Homepage: https://www.hcaptcha.com/ + * Documentation (vendor): https://docs.hcaptcha.com/ + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/hcaptcha + */ +var hCaptcha = await captcha.SolveHCaptcha("SITE_KEY", "https://WEBSITE_URL"); + +/* + * Type: GeeTest + * + * Homepage: https://www.geetest.com/en + * Documentation (vendor): https://docs.geetest.com/en + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/geetest + */ +var geeTest = await captcha.SolveGeeTest("SITE_KEY", "https://WEBSITE_URL", "CHALLENGE"); + +/* + * Type: FunCaptcha + * + * Documentation (anti-captcha): https://anti-captcha.com/apidoc/funcaptcha + */ +var funCaptcha = await captcha.SolveFunCaptcha("SITE_KEY", "https://WEBSITE_URL"); + +/* + * Type: SquareNet + */ +var squareNet = await captcha.SolveSquareNet("BASE64_IMAGE", "OBJECT_NAME", 3, 3); ``` ### And here is the result structure *(the same for all methods)*