{"id":29168273,"url":"https://github.com/Remarkable-Solutions/Selenium.AntiCaptcha","last_synced_at":"2025-07-01T10:06:08.759Z","repository":{"id":65232769,"uuid":"496774041","full_name":"Remarkable-Solutions/Selenium.AntiCaptcha","owner":"Remarkable-Solutions","description":"A powerful .NET library that integrates Selenium WebDriver with Anti-Captcha.com's API to automatically solve various types of CAPTCHAs on web pages.","archived":false,"fork":false,"pushed_at":"2025-06-21T11:42:23.000Z","size":37890,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-01T10:06:07.193Z","etag":null,"topics":["anticaptcha","captcha-solver","captcha-solver-api","captcha-solver-funcaptcha","captcha-solver-turnstile","captcha-solving","captcha-solving-service","selenium"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Remarkable-Solutions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-26T21:15:28.000Z","updated_at":"2025-07-01T09:26:18.000Z","dependencies_parsed_at":"2025-05-15T03:15:17.328Z","dependency_job_id":null,"html_url":"https://github.com/Remarkable-Solutions/Selenium.AntiCaptcha","commit_stats":{"total_commits":64,"total_committers":4,"mean_commits":16.0,"dds":0.1875,"last_synced_commit":"45f1c979249e3dddd1cf2fe83f7ef1cf85696120"},"previous_names":["remarkablesolutionsadmin/selenium.anticaptcha"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/Remarkable-Solutions/Selenium.AntiCaptcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Remarkable-Solutions%2FSelenium.AntiCaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Remarkable-Solutions%2FSelenium.AntiCaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Remarkable-Solutions%2FSelenium.AntiCaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Remarkable-Solutions%2FSelenium.AntiCaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Remarkable-Solutions","download_url":"https://codeload.github.com/Remarkable-Solutions/Selenium.AntiCaptcha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Remarkable-Solutions%2FSelenium.AntiCaptcha/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262941560,"owners_count":23388150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anticaptcha","captcha-solver","captcha-solver-api","captcha-solver-funcaptcha","captcha-solver-turnstile","captcha-solving","captcha-solving-service","selenium"],"created_at":"2025-07-01T10:06:07.924Z","updated_at":"2025-07-01T10:06:08.736Z","avatar_url":"https://github.com/Remarkable-Solutions.png","language":"C#","readme":"# Selenium.AntiCaptcha\n# Selenium.AntiCaptcha\n\nA powerful .NET library that integrates Selenium WebDriver with Anti-Captcha.com's API to automatically solve various types of CAPTCHAs on web pages.\n\n[![NuGet](https://img.shields.io/nuget/v/Selenium.AntiCaptcha.svg)](https://www.nuget.org/packages/Selenium.AntiCaptcha/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Features\n\n- 🔍 **Automatic CAPTCHA detection** - Identifies CAPTCHAs on the page without manual configuration\n- 🛡️ **Multi-CAPTCHA support** - Works with ReCaptcha v2/v3, FunCaptcha, GeeTest, Turnstile, and more\n- 🔄 **Proxy support** - Works with or without proxies\n- 🚀 **Performance optimized** - Caches site keys and optimizes requests\n- ⚙️ **Highly configurable** - Customize timeouts, retries, and behavior\n- 🧩 **Easy integration** - Simple extension methods for Selenium WebDriver\n\n## Supported CAPTCHA Types\n\n- ReCaptcha v2 (with and without proxy)\n- ReCaptcha v2 Enterprise (with and without proxy)\n- ReCaptcha v3 (with and without proxy)\n- ReCaptcha v3 Enterprise\n- FunCaptcha (with and without proxy)\n- GeeTest v3/v4 (with and without proxy)\n- Image to Text captcha\n- Turnstile captcha (with and without proxy)\n- Image to Coordinates\n\n## Installation\nA .NET library designed to seamlessly integrate [Anti-Captcha.com](https://anti-captcha.com/) services with Selenium WebDriver, enabling automated solving of various captcha types during your web automation tasks.\n\nThis library leverages the `AntiCaptchaApi.Net` library for communication with the Anti-Captcha API and provides convenient extension methods for `IWebDriver`.\n\n## Features\n\nSupports a wide range of captcha types, including (but not limited to):\n\n*   ReCaptcha V2 (Normal and Invisible)\n*   ReCaptcha V2 Enterprise\n*   ReCaptcha V3\n*   FunCaptcha\n*   GeeTest (V3 and V4)\n*   ImageToText\n*   Turnstile\n\n## Installation\n\n1.  **Install via NuGet Package Manager:**\n    ```powershell\n    Install-Package Selenium.AntiCaptcha\n    ```\n    This will also install `AntiCaptchaApi.Net` as a dependency.\n\n## Configuration and Usage (Dependency Injection)\n\nThis library is designed to be used with .NET's built-in Dependency Injection (DI) system.\n\n**1. Register `IAnticaptchaClient`**\n\nIn your application's startup code (e.g., `Program.cs` for .NET 6+ or `Startup.cs` for older .NET Core versions), register the `IAnticaptchaClient` service provided by `AntiCaptchaApi.Net`:\n\n```csharp\n// Program.cs (.NET 6+)\nusing AntiCaptchaApi.Net.Extensions; // Required for AddAnticaptcha\n\nvar builder = WebApplication.CreateBuilder(args);\n\n// Add other services...\n\nbuilder.Services.AddAnticaptcha(\"YOUR_ANTI_CAPTCHA_API_KEY\", clientConfig =\u003e\n{\n    // Optional: Configure ClientConfig properties if needed\n    // clientConfig.MaxHttpRequestTimeMs = 45000; \n    // clientConfig.DefaultTimeout = TimeSpan.FromSeconds(120);\n});\n\nvar app = builder.Build();\n\n// ...\n```\n\nReplace `\"YOUR_ANTI_CAPTCHA_API_KEY\"` with your actual API key from Anti-Captcha.com.\n\n**2. Inject `IAnticaptchaClient`**\n\nInject the `IAnticaptchaClient` into any service where you need to solve captchas:\n\n```csharp\nusing AntiCaptchaApi.Net;\nusing OpenQA.Selenium;\nusing Selenium.AntiCaptcha; // Required for IWebDriver extensions\nusing Selenium.AntiCaptcha.Models;\n\npublic class MyAutomatedTaskService\n{\n    private readonly IWebDriver _driver;\n    private readonly IAnticaptchaClient _anticaptchaClient;\n\n    public MyAutomatedTaskService(IWebDriver webDriver, IAnticaptchaClient anticaptchaClient)\n    {\n        _driver = webDriver;\n        _anticaptchaClient = anticaptchaClient;\n    }\n\n    public async Task PerformTaskWithCaptcha()\n    {\n        _driver.Navigate().GoToUrl(\"your_target_website_with_captcha\");\n\n        // Prepare solver arguments\n        var solverArgs = new SolverArguments\n        {\n            WebsiteUrl = _driver.Url,\n            // WebsiteKey = \"your_recaptcha_site_key\", // If known, otherwise it might be auto-detected for some types\n            // CaptchaType = CaptchaType.ReCaptchaV2, // Specify if known, otherwise auto-detection will be attempted\n            // ProxyConfig = new ProxyConfig { /* ... if using a proxy for solving ... */ }\n        };\n        \n        var actionArgs = new ActionArguments\n        {\n            // Specify elements to interact with after solving, if needed\n            // ResponseElement = _driver.FindElement(By.Id(\"g-recaptcha-response\")),\n            // SubmitElement = _driver.FindElement(By.Id(\"submit-button\"))\n        };\n\n        try\n        {\n            // Call the SolveCaptchaAsync extension method\n            var solutionResponse = await _driver.SolveCaptchaAsync(_anticaptchaClient, solverArgs, actionArgs);\n\n            if (solutionResponse.ErrorId \u003e 0)\n            {\n                Console.WriteLine($\"Anti-Captcha Error: {solutionResponse.ErrorDescription}\");\n                // Handle error\n            }\n            else\n            {\n                // For generic response, you might need to cast or check the specific solution type\n                // if (solutionResponse is TaskResultResponse\u003cRecaptchaSolution\u003e recaptchaSolution)\n                // {\n                //     Console.WriteLine($\"Captcha solved! Token: {recaptchaSolution.Solution.GRecaptchaResponse}\");\n                // }\n                Console.WriteLine(\"Captcha solved successfully (details depend on captcha type).\");\n                // Proceed with automated task\n            }\n        }\n        catch (Exception ex)\n        {\n            Console.WriteLine($\"An error occurred: {ex.Message}\");\n            // Handle exceptions (e.g., UnidentifiableCaptchaException, InsufficientSolverArgumentsException)\n        }\n    }\n    \n    // Example for a specific solution type\n    public async Task SolveReCaptchaV2Specifically()\n    {\n        _driver.Navigate().GoToUrl(\"your_recaptcha_v2_page\");\n\n        var solverArgs = new SolverArguments(_driver.Url, \"your_recaptcha_site_key\", CaptchaType.ReCaptchaV2);\n        \n        var result = await _driver.SolveCaptchaAsync\u003cAntiCaptchaApi.Net.Models.Solutions.RecaptchaSolution\u003e(_anticaptchaClient, solverArgs);\n\n        if (result.ErrorId == 0)\n        {\n            Console.WriteLine($\"ReCaptcha V2 solved! Token: {result.Solution.GRecaptchaResponse}\");\n            // Use the token (e.g., set it in a hidden field)\n        }\n        else\n        {\n            Console.WriteLine($\"Error solving ReCaptcha V2: {result.ErrorDescription}\");\n        }\n    }\n}\n```\n\n**3. Solver Arguments (`SolverArguments`)**\n\nThe `SolverArguments` class allows you to provide necessary details for the captcha solving task:\n\n*   `CaptchaType` (optional): Explicitly specify the `Selenium.AntiCaptcha.Enums.CaptchaType`. If not provided, the library will attempt to identify it.\n*   `WebsiteUrl` (often required): The URL of the page where the captcha is present.\n*   `WebsiteKey` (often required for ReCaptcha, FunCaptcha, etc.): The site key associated with the captcha.\n*   `ImageElement` (for ImageToText): The `IWebElement` pointing to the captcha image.\n*   `ImageFilePath` (for ImageToText): Path to a local image file.\n*   `ProxyConfig` (optional): If the captcha needs to be solved using a specific proxy, configure it here.\n    *   `ProxyType`\n    *   `ProxyAddress`\n    *   `ProxyPort`\n    *   `ProxyLogin` (optional)\n    *   `ProxyPassword` (optional)\n*   Other captcha-specific parameters (e.g., `MinScoreForRecaptchaV3`, `GeeTestChallenge`, `FunCaptchaApiJsSubdomain`).\n\n**4. Action Arguments (`ActionArguments`)**\n\nThe `ActionArguments` class allows you to specify Selenium elements to interact with after a successful solve:\n\n*   `ResponseElement`: An `IWebElement` (e.g., a textarea) where the captcha solution token should be placed.\n*   `SubmitElement`: An `IWebElement` (e.g., a submit button) to be clicked after the token is placed.\n*   `ShouldFindAndFillAccordingResponseElements`: If true, the library will attempt to find common response elements for certain captcha types.\n*   `ShouldResetCookiesBeforeAdd`: If true, cookies returned by Anti-Captcha (e.g., for AntiGate) will clear existing cookies before being added.\n\n## Migration from Older Versions\n\nIf you were using a version of this library that accepted a `clientKey` string directly in the `SolveCaptchaAsync` methods, please see the [MIGRATION.md](MIGRATION.md) guide for details on updating your code.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit issues or pull requests.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRemarkable-Solutions%2FSelenium.AntiCaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRemarkable-Solutions%2FSelenium.AntiCaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRemarkable-Solutions%2FSelenium.AntiCaptcha/lists"}