CaptchaSharp 1.0.11
See the version list below for details.
dotnet add package CaptchaSharp --version 1.0.11
NuGet\Install-Package CaptchaSharp -Version 1.0.11
<PackageReference Include="CaptchaSharp" Version="1.0.11" />
paket add CaptchaSharp --version 1.0.11
#r "nuget: CaptchaSharp, 1.0.11"
// Install CaptchaSharp as a Cake Addin #addin nuget:?package=CaptchaSharp&version=1.0.11 // Install CaptchaSharp as a Cake Tool #tool nuget:?package=CaptchaSharp&version=1.0.11
CaptchaSharp
A .NET Standard 2.0 library that implements the APIs of the most used captcha solving services out there.
The library is fully documented, asynchronous and very easy to use. All services derive from the same CaptchaService
class so you can allow users to use their favourite service without the need of a separate library for each one of them!
Supported Captchas
This library supports the following captcha types
- Text (with language options)
- Image (with options like phrase, case sensitivity, calculations)
- FunCaptcha
- ReCaptcha V2 (incl. invisible, enterprise)
- ReCaptcha V3 (incl. enterprise)
- HCaptcha
- KeyCaptcha
- GeeTest
- Capy
Although this sounds very exciting, sadly not all captcha types are supported by the services. You can find a table of the supported captcha types for each major service below.
Adding CaptchaSharp to your project
Simply install the nuget package via
Install-Package CaptchaSharp
If you need more solvers you can install additional solvers (mostly ones that implement the 2captcha API) like this
Install-Package CaptchaSharp.Services.More
Usage
First of all, initialize your solver of choice by providing your credentials, for example
CaptchaService service = new TwoCaptchaService("MY_API_KEY");
You can get your remaining balance like this
decimal balance = await service.GetBalanceAsync();
If the provided credentials are wrong, the method above will return a BadAuthenticationException
that you can catch and process in order to let the user know he needs to check his credentials.
If the credentials are correct and the balance is greater than the minimum required for solving a captcha, we can proceed to solve a ReCaptchaV2 task (you will need to provide the required parameters found in the webpage source code).
StringResponse solution = await service.SolveRecaptchaV2Async("site key", "site url");
The method above can throw the following exceptions:
TaskCreationException
when the task could not be created for example due to zero balance or incorrect parameters.TaskSolutionException
when the task could not be completed, for example when an image captcha cannot be decoded.TimeoutException
when the captcha solution took too long to complete.
You can configure a custom timeout like this
service.Timeout = TimeSpan.FromMinutes(3);
The returned StringResponse
will contain two fields:
An Id
which you can use for reporting a bad solution (if the service supports it) like this
await service.ReportSolution(solution.Id, CaptchaType.ReCaptchaV2);
if the report failed, the method above will throw a TaskReportException
.
And finally your solution as plaintext
Console.WriteLine($"The solution is {solution.Response}");
In addition, mind that not every service supports every type of captcha! If a method or specific parameters are not supported, a NotSupportedException
will be thrown.
Unit Tests
Unit tests for the major services are included in the CaptchaSharp.Tests
project. In order to test, you need to:
- Run any test once and let it fail. It will create a file called
config.json
in yourbin/Debug
folder. - Add your credentials to the
config.json
file. You can also add a proxy to test proxied endpoints. - Run the tests (one at a time, to avoid overloading the service and overspending).
- If you need to test a captcha on a specific website, you can edit the
ServiceTests
class and change the parameters as you need.
What needs to be improved
- Use C# anonymous types or
JObject
for theAntiCaptchaSolver
instead of a million classes! - Implement better exception handling, for example when there is zero balance or when a solver method returns a bad authentication, they will currently fall in the generic
TaskCreationException
type.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CaptchaSharp:
Package | Downloads |
---|---|
CaptchaSharp.Services.More
Adds additional services to CaptchaSharp. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on CaptchaSharp:
Repository | Stars |
---|---|
openbullet/OpenBullet2
OpenBullet reinvented
|
|
openbullet/openbullet
The OpenBullet web testing application.
|
Version | Downloads | Last updated |
---|---|---|
2.1.0 | 1,636 | 8/12/2024 |
2.0.0 | 1,861 | 8/3/2024 |
1.0.13 | 28,519 | 1/30/2023 |
1.0.12 | 371 | 1/24/2023 |
1.0.11 | 9,997 | 11/28/2022 |
1.0.10 | 4,738 | 1/10/2022 |
1.0.9 | 5,209 | 1/2/2022 |
1.0.8 | 1,717 | 9/20/2021 |
1.0.7 | 1,464 | 7/2/2021 |
1.0.6 | 4,455 | 3/28/2021 |
1.0.5 | 954 | 3/2/2021 |
1.0.4 | 9,643 | 6/11/2020 |
1.0.3 | 1,182 | 5/15/2020 |
1.0.2 | 519 | 5/14/2020 |
1.0.1 | 790 | 4/15/2020 |
1.0.0 | 691 | 4/15/2020 |
Added capsolver.com and datadome captcha