Skip to content

Commit

Permalink
Fixed repo logo, Updated nuget metadata, Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaczero committed Mar 26, 2020
1 parent 7366344 commit 22f52a6
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 74 deletions.
19 changes: 11 additions & 8 deletions AntiCaptcha.Sandbox/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Net.Http;
using System.Threading.Tasks;

namespace _AntiCaptcha.Test
Expand All @@ -12,26 +13,28 @@ static void Main(string[] args)

static async Task Foo()
{
var antiCaptcha = new AntiCaptcha(" ## YOUR API KEY ## ");
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
var balance = await antiCaptcha.GetBalance();
var balance = await captcha.GetBalance();

// Solve image captcha
var image = await antiCaptcha.SolveImage("iVBORw0KGgo...");
var image = await captcha.SolveImage("iVBORw0KGgo...");

// Solve ReCaptchaV2
var recaptcha = await antiCaptcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com");
var recaptchaInvisible = await antiCaptcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com", true);
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 antiCaptcha.SolveFunCaptcha("FUN_CAPTCHA_PUBLIC_KEY", "https://example.com");
var fun = await captcha.SolveFunCaptcha("FUN_CAPTCHA_PUBLIC_KEY", "https://example.com");

// Solve SquareNet
var square = await antiCaptcha.SolveSquareNet("iVBORw0KGgo...", "banana", 3, 3);
var square = await captcha.SolveSquareNet("iVBORw0KGgo...", "banana", 3, 3);

// Solve GeeTest
var gee = await antiCaptcha.SolveGeeTest("GEE_TEST_KEY", "https://example.com", "CHALLENGE");
var gee = await captcha.SolveGeeTest("GEE_TEST_KEY", "https://example.com", "CHALLENGE");

Debugger.Break();
}
Expand Down
22 changes: 11 additions & 11 deletions AntiCaptcha/AntiCaptcha.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AntiCaptcha
#if NETSTANDARD2_0
[Serializable]
#endif
private struct AntiCaptchaResponse
private struct AntiCaptchaApiResponse
{
public int ErrorId;
public string ErrorCode;
Expand All @@ -27,9 +27,9 @@ private struct AntiCaptchaResponse
private readonly HttpClient _httpClient;
private readonly string _apiKey;

public AntiCaptcha(string apiKey)
public AntiCaptcha(string apiKey, HttpClient httpClient = null)
{
_httpClient = new HttpClient();
_httpClient = httpClient ?? new HttpClient();
_apiKey = apiKey;
}

Expand All @@ -44,7 +44,7 @@ public async Task<AntiCaptchaResult> GetBalance(CancellationToken cancellationTo
var inResponse = await _httpClient.PostAsync(BaseUrl + "getBalance", new StringContent(contentJson), cancellationToken).ConfigureAwait(false);
var inJson = await inResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

var @in = JsonConvert.DeserializeObject<AntiCaptchaResponse>(inJson);
var @in = JsonConvert.DeserializeObject<AntiCaptchaApiResponse>(inJson);
if (@in.ErrorId != 0)
{
return new AntiCaptchaResult(false, @in.ErrorCode);
Expand All @@ -53,25 +53,25 @@ public async Task<AntiCaptchaResult> GetBalance(CancellationToken cancellationTo
return new AntiCaptchaResult(true, @in.Balance.ToString());
}

private async Task<InternalAntiCaptchaResult> Solve(int delaySeconds, IDictionary<string, object> content, CancellationToken cancellationToken = default)
private async Task<AntiCaptchaResultInternal> Solve(int delaySeconds, IDictionary<string, object> content, CancellationToken cancellationToken = default)
{
content["clientKey"] = _apiKey;

var contentJson = JsonConvert.SerializeObject(content);
var inResponse = await _httpClient.PostAsync(BaseUrl + "createTask", new StringContent(contentJson), cancellationToken).ConfigureAwait(false);
var inJson = await inResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

var @in = JsonConvert.DeserializeObject<AntiCaptchaResponse>(inJson);
var @in = JsonConvert.DeserializeObject<AntiCaptchaApiResponse>(inJson);
if (@in.ErrorId != 0)
{
return new InternalAntiCaptchaResult(false, @in.ErrorCode, null);
return new AntiCaptchaResultInternal(false, @in.ErrorCode, null);
}

await Task.Delay(delaySeconds * 1000, cancellationToken).ConfigureAwait(false);
return await GetResponse(@in.TaskId, cancellationToken).ConfigureAwait(false);
}

private async Task<InternalAntiCaptchaResult> GetResponse(int taskId, CancellationToken cancellationToken = default)
private async Task<AntiCaptchaResultInternal> GetResponse(int taskId, CancellationToken cancellationToken = default)
{
var content = new Dictionary<string, object>
{
Expand All @@ -86,10 +86,10 @@ private async Task<InternalAntiCaptchaResult> GetResponse(int taskId, Cancellati
var response = await _httpClient.PostAsync(BaseUrl + "getTaskResult", new StringContent(contentJson), cancellationToken).ConfigureAwait(false);
var responseJson = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

var res = JsonConvert.DeserializeObject<AntiCaptchaResponse>(responseJson);
var res = JsonConvert.DeserializeObject<AntiCaptchaApiResponse>(responseJson);
if (res.ErrorId != 0)
{
return new InternalAntiCaptchaResult(false, res.ErrorCode, null);
return new AntiCaptchaResultInternal(false, res.ErrorCode, null);
}

if (res.Status == "processing")
Expand All @@ -98,7 +98,7 @@ private async Task<InternalAntiCaptchaResult> GetResponse(int taskId, Cancellati
continue;
}

return new InternalAntiCaptchaResult(true, null, res.Solution);
return new AntiCaptchaResultInternal(true, null, res.Solution);
}
}

Expand Down
19 changes: 14 additions & 5 deletions AntiCaptcha/AntiCaptcha.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,30 @@
<RootNamespace>_AntiCaptcha</RootNamespace>
<Authors>Zaczero (Kamil Monicz)</Authors>
<Description>Simple API wrapper for https://anti-captcha.com/</Description>
<Copyright>Copyright (c) Zaczero (Kamil Monicz) 2019</Copyright>
<Copyright>Copyright © Kamil Monicz 2020</Copyright>
<PackageLicenseUrl></PackageLicenseUrl>
<PackageProjectUrl>https://github.com/Zaczero/AntiCaptcha</PackageProjectUrl>
<PackageIconUrl>https://i.imgur.com/U0qKP3j.png</PackageIconUrl>
<Version>1.1.0</Version>
<PackageIconUrl></PackageIconUrl>
<Version>1.2</Version>
<PackageTags>anticaptcha, captcha, solver, recaptcha, google, text, image, wrapper, api</PackageTags>
<PackageId>AntiCaptchaAPI</PackageId>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<FileVersion>1.2.0.0</FileVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/Zaczero/AntiCaptcha</RepositoryUrl>
<PackageIcon>AntiCaptcha.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>

<ItemGroup>
<None Include="..\resources\AntiCaptcha.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions AntiCaptcha/AntiCaptchaResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public AntiCaptchaResult(bool success, string response)
}
}

internal struct InternalAntiCaptchaResult
internal struct AntiCaptchaResultInternal
{
public bool Success;
public string Response;
public Dictionary<string, object> Dictionary;

public InternalAntiCaptchaResult(bool success, string response, Dictionary<string, object> dictionary)
public AntiCaptchaResultInternal(bool success, string response, Dictionary<string, object> dictionary)
{
Success = success;
Response = response;
Expand Down
89 changes: 41 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,74 @@
# ![2Captcha logo](https://i.imgur.com/U0qKP3j.png)
# ![Zaczero/AntiCaptcha logo](https://github.com/Zaczero/AntiCaptcha/blob/master/resources/AntiCaptcha.png)

![](https://img.shields.io/github/release/Zaczero/AntiCaptcha.svg)
![](https://img.shields.io/nuget/v/AntiCaptchaAPI.svg)
![](https://img.shields.io/github/license/Zaczero/AntiCaptcha.svg)
![github version](https://img.shields.io/github/release/Zaczero/AntiCaptcha.svg)
![nuget version](https://img.shields.io/nuget/v/AntiCaptchaAPI.svg)
![license type](https://img.shields.io/github/license/Zaczero/AntiCaptcha.svg)

Simple HTTP API wrapper for https://anti-captcha.com/
Simple HTTP API wrapper for [anti-captcha.com](https://anti-captcha.com/)
An online captcha solving and image recognition service.

## 🔗 Download
* Latest release: https://github.com/Zaczero/AntiCaptcha/releases/latest
## 🌤️ Installation

## ☕ Support me
If you find this project useful and you are new to anti captcha please consider registering from my [referrral link](http://getcaptchasolution.com/i4lbjatsex).
### Install with NuGet (recommended)

## 🏁 Sample code
`Install-Package AntiCaptchaAPI`

### Install manually

[Browse latest GitHub release](https://github.com/Zaczero/AntiCaptcha/releases/latest)

## 🏁 Getting started

### Sample code

```cs
var antiCaptcha = new AntiCaptcha(" ## YOUR API KEY ## ");
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
var balance = await antiCaptcha.GetBalance();
var balance = await captcha.GetBalance();

// Solve image captcha
var image = await antiCaptcha.SolveImage("iVBORw0KGgo...");
var image = await captcha.SolveImage("iVBORw0KGgo...");

// Solve ReCaptchaV2
var recaptcha = await antiCaptcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com");
var recaptchaInvisible = await antiCaptcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com", true);
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 antiCaptcha.SolveFunCaptcha("FUN_CAPTCHA_PUBLIC_KEY", "https://example.com");
var fun = await captcha.SolveFunCaptcha("FUN_CAPTCHA_PUBLIC_KEY", "https://example.com");

// Solve SquareNet
var square = await antiCaptcha.SolveSquareNet("iVBORw0KGgo...", "banana", 3, 3);
var square = await captcha.SolveSquareNet("iVBORw0KGgo...", "banana", 3, 3);

// Solve GeeTest
var gee = await antiCaptcha.SolveGeeTest("GEE_TEST_KEY", "https://example.com", "CHALLENGE");

Debugger.Break();
var gee = await captcha.SolveGeeTest("GEE_TEST_KEY", "https://example.com", "CHALLENGE");
```

### And here is the result structure *(same for all methods)*:
### And here is the result structure *(the same for all methods)*

```cs
public struct AntiCaptchaResult
{
public bool Success;
public string Response;

public AntiCaptchaResult(bool success, string response)
{
Success = success;
Response = response;
}
public bool Success;
public string Response;

public AntiCaptchaResult(bool success, string response)
{
Success = success;
Response = response;
}
}
```

## 📎 License

MIT License
## Footer

Copyright (c) 2019 Kamil Monicz
### 📧 Contact

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
* Email: [kamil@monicz.pl](mailto:kamil@monicz.pl)

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
### 📃 License

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
* [Zaczero/AntiCaptcha](https://github.com/Zaczero/AntiCaptcha/blob/master/LICENSE)
* [JamesNK/Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md)
Binary file added resources/AntiCaptcha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 22f52a6

Please sign in to comment.