Giter Club home page Giter Club logo

2captcha's Introduction

Zaczero/2Captcha logo

Build Status Github Release NuGet Release License

Simple HTTP API wrapper for 2captcha.com. An online captcha solving and image recognition service.

By using this library you will get 10% cashback on captchas you solve.

🌤️ Installation

Install with NuGet (recommended)

Install-Package 2CaptchaAPI

Install manually

Browse latest GitHub release

🏁 Getting started

Sample code

/*
 * Class initialization
 * Optionally you can pass 2nd parameter `httpClient` with custom HttpClient to use while requesting API
 */
var captcha = new _2Captcha("API_KEY");
var captchaCustomHttp = new _2Captcha("API_KEY", new HttpClient());

/*
 * Set custom API url (optional)
 */
captcha.SetApiUrl("https://CUSTOM_URL");

/*
 * Get current balance
 */
var balance = await captcha.GetBalance();

/*
 * Type: Image
 *
 * Documentation (2captcha): https://2captcha.com/2captcha-api#solving_normal_captcha
 */
var image = await captcha.SolveImage(new FileStream("captcha.png", FileMode.Open), FileType.Png);
var image2 = await captcha.SolveImage(File.ReadAllBytes("captcha.png"), FileType.Png);
var image3 = await captcha.SolveImage("BASE64_IMAGE", FileType.Png);

var imageCaseSensitive = await captcha.SolveImage(new FileStream("captcha.png", FileMode.Open), FileType.Png, new KeyValuePair<string, string>("regsense", "1"));
var imageCaseSensitive2 = await captcha.SolveImage(File.ReadAllBytes("captcha.png"), FileType.Png, new KeyValuePair<string, string>("regsense", "1"));
var imageCaseSensitive3 = await captcha.SolveImage("BASE64_IMAGE", FileType.Png, new KeyValuePair<string, string>("regsense", "1"));

/*
 * Type: Text
 *
 * Documentation (2captcha): https://2captcha.com/2captcha-api#solving_text_captcha
 */
var question = await captcha.SolveQuestion("1 + 3 = ?");

/*
 * 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 (2captcha): https://2captcha.com/2captcha-api#solving_recaptchav2_new
 */
var reCaptcha = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL");
var reCaptchaInvisible = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL", true);
var reCaptchaWithProxy = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL", "username:password@address:port", ProxyType.Http);

/*
 * Type: ReCaptcha V3
 *
 * Homepage: https://www.google.com/recaptcha/
 * Documentation (vendor): https://developers.google.com/recaptcha/docs/v3
 * Documentation (2captcha): https://2captcha.com/2captcha-api#solving_recaptchav3
 */
var reCaptchaV3 = await captcha.SolveReCaptchaV3("SITE_KEY", "https://WEBSITE_URL", "ACTION", 0.4);
var reCaptchaV3WithProxy = await captcha.SolveReCaptchaV3("SITE_KEY", "https://WEBSITE_URL", "username:password@address:port", ProxyType.Http, "ACTION", 0.4);

/*
 * Type: hCaptcha
 *
 * Homepage: https://www.hcaptcha.com/
 * Documentation (vendor): https://docs.hcaptcha.com/
 * Documentation (2captcha): https://2captcha.com/2captcha-api#solving_hcaptcha
 */
var hCaptcha = await captcha.SolveHCaptcha("SITE_KEY", "https://WEBSITE_URL");
var hCaptchaWithProxy = await captcha.SolveHCaptcha("SITE_KEY", "https://WEBSITE_URL", "username:password@address:port", ProxyType.Http);

/*
 * Type: GeeTest
 *
 * Homepage: https://www.geetest.com/en
 * Documentation (vendor): https://docs.geetest.com/en
 * Documentation (2captcha): https://2captcha.com/2captcha-api#solving_geetest
 */
var geeTest = await captcha.SolveGeeTest("SITE_KEY", "https://WEBSITE_URL", "CHALLENGE");

/*
 * Type: ClickCaptcha
 *
 * Documentation (2captcha): https://2captcha.com/2captcha-api#solving_clickcaptcha
 */
var clickCaptcha = await captcha.SolveClickCaptcha(new FileStream("captcha.png", FileMode.Open), FileType.Png, "TASK");
var clickCaptcha2 = await captcha.SolveClickCaptcha(File.ReadAllBytes("captcha.png"), FileType.Png, "TASK");
var clickCaptcha3 = await captcha.SolveClickCaptcha("BASE64_IMAGE", FileType.Png, "TASK");

/*
 * Type: RotateCaptcha
 *
 * Documentation (2captcha): https://2captcha.com/2captcha-api#solving_rotatecaptcha
 */
var rotateCaptcha = await captcha.SolveRotateCaptcha(
    new Stream[]
    {
        new FileStream("captcha1.png", FileMode.Open),
        new FileStream("captcha2.png", FileMode.Open),
        new FileStream("captcha3.png", FileMode.Open),
    }, FileType.Png, "40");

/*
 * Type: FunCaptcha
 *
 * Documentation (2captcha): https://2captcha.com/2captcha-api#solving_funcaptcha_new
 */
var funCaptcha = await captcha.SolveFunCaptcha("PUBLIC_KEY", "https://WEBSITE_URL");
var funCaptchaNoJavaScript = await captcha.SolveFunCaptcha("PUBLIC_KEY", "https://WEBSITE_URL", true);
var funCaptchaWithProxy = await captcha.SolveFunCaptcha("PUBLIC_KEY", "https://WEBSITE_URL", "username:password@address:port", ProxyType.Http);

/*
 * Type: KeyCaptcha
 *
 * Homepage: https://www.keycaptcha.com/
 * Documentation (2captcha): https://2captcha.com/2captcha-api#solving_keycaptcha
 */
var keyCaptcha = await captcha.SolveKeyCaptcha("USER_ID", "SESSION_ID", "WEB_SIGN_1", "WEB_SIGN_2", "https://WEBSITE_URL");

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

public struct Result
{
    public readonly bool Success;
    public readonly JToken ResponseObject;

    public string ResponseJson;
    public string Response;
    public double ResponseDouble;
    public Coordinates[] ResponseCoordinates;
}

Footer

📧 Contact

📃 License

2captcha's People

Contributors

aeonlucid avatar callumas avatar jtone123 avatar liubicai avatar mboukhlouf avatar ryuzakih avatar zaczero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

2captcha's Issues

Any luck with Outlook Rotatecaptcha?

According to 2Captcha api, we have to send them the captcha images for RotateCaptchas but on Outlook, the captcha image are being rendered via some JS tricks as we can not even inspect the image url from the canvas. I was wondering if you have any knowledge around it that can help solve my issue.
image

please help me

Hello friend like this, I am interested in making your program for 2 captchas, and actually I would like to know how to run it, and what steps should I follow please

Sending Images fails

I used your Nuget package first for a rotate captcha request (c#, framework 4.6.1)
Always failed with 'ERROR_ROTATECAPTCHA' in the response.
Went here to look at the source code: SolveRotateCaptcha(stream(),angle) does not send a filename, nor does it add a content-type header.
Changing the source to add filename: 'test.png' solved the issue.

2 Warnings

Field 'TwoCaptcha.TwoCaptchaResponse.Status' is never assigned to, and will always have its default value 0

Field 'TwoCaptcha.TwoCaptchaResponse.Request' is never assigned to, and will always have its default value `null'

Can you use http instead of https ?

Hi,
i'd love to use your great lib with other services (like death by captcha or local software like xevil) which provide a 2captcha compatible api endpoint (though they just provide a subset of features)

They usually can be used by setting the 2captcha.com DNS record via hosts file to their IP
But this fails with your lib because they only can provide a http service on port 80 cause of the ssl certificate.

So as original 2captcha also works great via http, i think there would no harm to just use http instead of https

Help me (It's not a bug, it's me dumb)

Here, I downloaded package from Nuget. So copy-pasted your code and do not work, ahah. Sorry for it, but with other codes I just used alt+enter and libs connected by themselves. Here I also tried using _2Captcha, it worked, but the error still same.

image
image

Newtonsoft.Json.JsonReaderException occurred

Hello Zaczero,

Thank you for nice library, but I got an error. You can see my code below:

var captcha = new _2Captcha(<my_API_key>);
KeyValuePair<string, string>[] options = new KeyValuePair<string, string>[]
{
// I have to add this because my language isn't English
new KeyValuePair<string, string>("textinstructions","Select icons in the order required")
};
var clickCaptcha = await captcha.SolveClickCaptcha(ImageToBase64String("captcha.png"), FileType.Png, "TASK", options);

The captcha has been solved (I checked in my dashboard at 2captcha.com). But Newtonsoft.Json.JsonReaderException occurred. Error message is

{"Unexpected character encountered while parsing value: [. Path 'request', line 1, position 23."}

I see in VS , the return object is {Success: false, Response: null}
Please help me! Thank you very much.

(solved) Biblioteka "zawiesza" program

Witam ponownie.

Niestety nie wiem co robię źle ale biblioteka mi nie działa.

Mam następujący kod (wzięty z rozwiązania przykładowego)

 var twoCaptcha = new TwoCaptcha("API ID");
// Get current balance
// var balance = twoCaptcha.GetBalance().Result;

// Solve image captcha
var image1 = twoCaptcha.SolveImage(new FileStream("c:\\ESD\\doc\\captcha.png", FileMode.Open)).Result;

W momencie wejścia uruchomienia linii kodu zawierającej GetBalance lub Solveimage program zatrzymuje się na tej linii. Diagnostyka przy wspomnianej linii podaje komunikat "To jest następna instrukcja, która zostanie wykonana po powrocie tego wątku z bieżącej funkcji".
Dalsza analiza po pobraniu źródeł biblioteki i umieszczeniu ich w programie zamiast biblioteki dll pobranej z NuGet, wskazuje na problem w linii kodu zawierającej:

var inResponse = await _httpClient.PostAsync(*****)

Oczywiście zamiast gwiazdek jest odpowiedni kod wysyłający png lub pytający o saldo.

Na wskazanej linii program zatrzymuje się choć Diagnostyka pokazuje, że działa dalej lecz nie reaguje na dalsze polecenia .

GetSaldo() lub tożsama nazwa ;)

Witam

Mam nadzieje że dobrze wywnioskowałem, i nie muszę pisać łamanym angielskim.

Czy była by możliwość abyś dodał funkcję odczytu salda na 2captcha.com?
Obecnie biblioteka tego nie oferuje (chyba że nie widzę tej opcji) i trzeba korzystać z własnego kodu.

Próbowałem dopisać tą funkcję do źródła i skompilować, ale mimo pozytywnej kompilacji i podmiany biblioteki, pisana aplikacja nie widzi nowo dodanej funkcji w bibliotece.

Pozdrawiam

sub users

is there a way to issue api keys to sub users so that their individual api calls can be tracked?

About Hcaptcha Sitekey

This is maybe not a code problem at all, but allow me to ask this.
I am somewhat new to this bypass thing, but I need to crawl some
website to collect data for my study purpose automatically done by
program, but there is more and more websites using cloudflare protection,
sometimes I need to deal with hCaptcha to collect data, but so for no luck,
and I found your thing man, this is pretty cool, and I just got
one question, how can I find out the so-called site-key to use your code to
bypass cloudflare hCaptcha?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.