
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Selenium.AntiCaptcha
Advanced tools
Selenium extension methods for captcha solving using Anti-Captcha.com API. Supports ReCaptcha v2/v3, FunCaptcha, GeeTest, Image to Text, Turnstile and more.
A powerful .NET library that integrates Selenium WebDriver with Anti-Captcha.com's API to automatically solve various types of CAPTCHAs on web pages.
A .NET library designed to seamlessly integrate Anti-Captcha.com services with Selenium WebDriver, enabling automated solving of various captcha types during your web automation tasks.
This library leverages the AntiCaptchaApi.Net
library for communication with the Anti-Captcha API and provides convenient extension methods for IWebDriver
.
Supports a wide range of captcha types, including (but not limited to):
Install-Package Selenium.AntiCaptcha
This will also install AntiCaptchaApi.Net
as a dependency.This library is designed to be used with .NET's built-in Dependency Injection (DI) system.
1. Register IAnticaptchaClient
In 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
:
// Program.cs (.NET 6+)
using AntiCaptchaApi.Net.Extensions; // Required for AddAnticaptcha
var builder = WebApplication.CreateBuilder(args);
// Add other services...
builder.Services.AddAnticaptcha("YOUR_ANTI_CAPTCHA_API_KEY", clientConfig =>
{
// Optional: Configure ClientConfig properties if needed
// clientConfig.MaxHttpRequestTimeMs = 45000;
// clientConfig.DefaultTimeout = TimeSpan.FromSeconds(120);
});
var app = builder.Build();
// ...
Replace "YOUR_ANTI_CAPTCHA_API_KEY"
with your actual API key from Anti-Captcha.com.
2. Inject IAnticaptchaClient
Inject the IAnticaptchaClient
into any service where you need to solve captchas:
using AntiCaptchaApi.Net;
using OpenQA.Selenium;
using Selenium.AntiCaptcha; // Required for IWebDriver extensions
using Selenium.AntiCaptcha.Models;
public class MyAutomatedTaskService
{
private readonly IWebDriver _driver;
private readonly IAnticaptchaClient _anticaptchaClient;
public MyAutomatedTaskService(IWebDriver webDriver, IAnticaptchaClient anticaptchaClient)
{
_driver = webDriver;
_anticaptchaClient = anticaptchaClient;
}
public async Task PerformTaskWithCaptcha()
{
_driver.Navigate().GoToUrl("your_target_website_with_captcha");
// Prepare solver arguments
var solverArgs = new SolverArguments
{
WebsiteUrl = _driver.Url,
// WebsiteKey = "your_recaptcha_site_key", // If known, otherwise it might be auto-detected for some types
// CaptchaType = CaptchaType.ReCaptchaV2, // Specify if known, otherwise auto-detection will be attempted
// ProxyConfig = new ProxyConfig { /* ... if using a proxy for solving ... */ }
};
var actionArgs = new ActionArguments
{
// Specify elements to interact with after solving, if needed
// ResponseElement = _driver.FindElement(By.Id("g-recaptcha-response")),
// SubmitElement = _driver.FindElement(By.Id("submit-button"))
};
try
{
// Call the SolveCaptchaAsync extension method
var solutionResponse = await _driver.SolveCaptchaAsync(_anticaptchaClient, solverArgs, actionArgs);
if (solutionResponse.ErrorId > 0)
{
Console.WriteLine($"Anti-Captcha Error: {solutionResponse.ErrorDescription}");
// Handle error
}
else
{
// For generic response, you might need to cast or check the specific solution type
// if (solutionResponse is TaskResultResponse<RecaptchaSolution> recaptchaSolution)
// {
// Console.WriteLine($"Captcha solved! Token: {recaptchaSolution.Solution.GRecaptchaResponse}");
// }
Console.WriteLine("Captcha solved successfully (details depend on captcha type).");
// Proceed with automated task
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
// Handle exceptions (e.g., UnidentifiableCaptchaException, InsufficientSolverArgumentsException)
}
}
// Example for a specific solution type
public async Task SolveReCaptchaV2Specifically()
{
_driver.Navigate().GoToUrl("your_recaptcha_v2_page");
var solverArgs = new SolverArguments(_driver.Url, "your_recaptcha_site_key", CaptchaType.ReCaptchaV2);
var result = await _driver.SolveCaptchaAsync<AntiCaptchaApi.Net.Models.Solutions.RecaptchaSolution>(_anticaptchaClient, solverArgs);
if (result.ErrorId == 0)
{
Console.WriteLine($"ReCaptcha V2 solved! Token: {result.Solution.GRecaptchaResponse}");
// Use the token (e.g., set it in a hidden field)
}
else
{
Console.WriteLine($"Error solving ReCaptcha V2: {result.ErrorDescription}");
}
}
}
3. Solver Arguments (SolverArguments
)
The SolverArguments
class allows you to provide necessary details for the captcha solving task:
CaptchaType
(optional): Explicitly specify the Selenium.AntiCaptcha.Enums.CaptchaType
. If not provided, the library will attempt to identify it.WebsiteUrl
(often required): The URL of the page where the captcha is present.WebsiteKey
(often required for ReCaptcha, FunCaptcha, etc.): The site key associated with the captcha.ImageElement
(for ImageToText): The IWebElement
pointing to the captcha image.ImageFilePath
(for ImageToText): Path to a local image file.ProxyConfig
(optional): If the captcha needs to be solved using a specific proxy, configure it here.
ProxyType
ProxyAddress
ProxyPort
ProxyLogin
(optional)ProxyPassword
(optional)MinScoreForRecaptchaV3
, GeeTestChallenge
, FunCaptchaApiJsSubdomain
).4. Action Arguments (ActionArguments
)
The ActionArguments
class allows you to specify Selenium elements to interact with after a successful solve:
ResponseElement
: An IWebElement
(e.g., a textarea) where the captcha solution token should be placed.SubmitElement
: An IWebElement
(e.g., a submit button) to be clicked after the token is placed.ShouldFindAndFillAccordingResponseElements
: If true, the library will attempt to find common response elements for certain captcha types.ShouldResetCookiesBeforeAdd
: If true, cookies returned by Anti-Captcha (e.g., for AntiGate) will clear existing cookies before being added.If you were using a version of this library that accepted a clientKey
string directly in the SolveCaptchaAsync
methods, please see the MIGRATION.md guide for details on updating your code.
Contributions are welcome! Please feel free to submit issues or pull requests.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
Selenium extension methods for captcha solving using Anti-Captcha.com API. Supports ReCaptcha v2/v3, FunCaptcha, GeeTest, Image to Text, Turnstile and more.
We found that selenium.anticaptcha demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.