Solving captchas with 2captcha.com in Human Emulator

Solving captchas with 2captcha.com in Human Emulator

2Captcha is a human-powered image and CAPTCHA recognition service.

The process of solving captchas.

  • We send the image to 2Captcha server.
  • The server returns a unique task identifier (Captcha ID).
  • Run a loop that checks whether the captcha is solved.
  • As a result, we get either the text of the captcha or data for substitution in the sources of the page, or an error from the service.

Working with API 2Captcha in the program is simplified as much as possible. For this Human Emulator object has been added twocaptcha.

Let’s go through the main functions for working with the service 2Captcha.

Normal Captcha.

To recognize simple captcha with distorted text, use the function recognize.

As a result, the function returns a string with the solution of the captcha, which we substitute further in the input field on the site.

Using the function parameters you can set any type of such captcha, text or numbers, language, number of characters in the captcha, etc.

Parameters:

  • filename – path to captcha file
  • apikey – key for identification on the service
  • path – the service path
  • is_verbose – enable/disable verbose mode (commenting on what is happening): false( disable), true (enable)
  • rtimeout – delay between polls of the status of the captcha
  • mtimeout – timeout enter the captcha
  • is_phrase – 0 or 1 – the flag “captcha contains two or more words”
  • is_regsense – 0 or 1 – the flag “captcha is case sensitive”
  • is_numeric – 0 – not specified; 1 – captcha contains only numbers; 2 – captcha contains only letters; 3 – captcha contains only numbers OR only letters; 4 – captcha contains both numbers AND letters
  • min_len – 0 (no limit), minimal number of symbols in captcha
  • max_len – 0 (no limit), maximal number of symbols in captcha
  • is_russian – 0 – not specified; 1 – Cyrillic captcha; 2 – Latin captcha

Example of use in php:

As a result of the script, the text of the recognized captcha will appear in the debug panel of Human Emulator.

Text Captcha.

Text captcha is when you have to answer a question. For example: If tomorrow is Saturday, what day is today?

To recognize such captchas use the function recognize_text.

As a parameter, pass the text to be answered.

As a result, we get the correct answer, which must be either entered in a input field or selected from a listbox.

Example of using the function in php:

As a result of the example, the text with the correct answer will appear in the debug panel of Human Emulator.

ReCaptcha V2 and Invisible ReCaptcha V2.

Very popular captcha from Google. Different Invisible ReCaptcha V2 from the conventional ReCaptcha V2, that invisible captcha appears only after some action, say clicking on a button or field, and ReCaptcha V2 is visible on the page at once and looks like this:

There are two solutions to these captcha. First, getting a token and substitution of this token in the field on the site, and clicking on the specified pictures. Consider both solutions.

1.Recognition using a token.

This function is used recognize_recaptcha_v2.

This function takes the following parameters:

  • pageurl – full URL of the page where you want to solve ReCaptcha V2
  • googlekey – the so-called a sitekey. For each site it is different, and it can be found in the source text of the captcha.
  • invisible – type of captcha. Default: 0. 1 – tells us that the site using invisible ReCaptcha V2.
  • proxy – proxy. When you authenticate on IP: Ip_address:PORT. Example: proxy=123.123.123.123:3128. When you authenticate using login and password: loginparameters. Example: proxy=proxyuser:strongPassword@123.123.123.123:3128
  • proxytype – the type of proxy: HTTP, HTTPS, SOCKS4, SOCKS5. Example: proxytype=SOCKS4

Proxy and proxytype parameters are not set for work without proxy.

After sending these parameters to the server 2captcha.com, in response comes the token this is the text like this:

As a rule, we substitute the token in the field with the id “g-recaptcha-response“, but it depends on the site, there may be options with other fields or calling the so-called Callback functions.

See a detailed description of the nuances of the recognition of ReCaptcha V2 on 2captcha.com.

Example of using the function for both variants of ReCaptcha V2:

As a result of correct recognition of the captcha in the program will open a page with the text “Verification Success… Hooray!“.

2.Clicking on pictures to recognize ReCaptcha V2.

To solve ReCaptcha V2 this method uses the function recognize_click_captcha.

The function accepts the following parameters:

  • filename – path to captcha image
  • textinstructions – the text of what you want to select in the picture in UTF-8 encoding. This parameter is not required, if the picture is clear where to click – you can not send it.

Example of the recognition of ReCaptcha V2 with clicks on images in php:

In the results of the example, the program clicks on the desired images. If the picture repeats, you need to send a new version, etc.

As you can see from the examples, the ReCaptcha V2 solution through a token is much easier than the option of clicking on the pictures, but in any case, both of these options work. The second method is suitable for all types of captcha, where you have to click on the pictures.

Recognition GeeTest captcha.

In GeeTest captcha, you need to select several objects or move a piece of the puzzle in the right order.

For raspoznanie this type of captcha in Human Emulator function is used recognize_geetest.

The following parameters must be passed for correct recognition:

  • pageurl – Full URL of the page where you see GeeTest captcha
  • gt – public website key (static)
  • challenge – dynamic challenge key
  • api_server – API domain (optional)
  • proxy – proxy. When you authenticate on IP: Ip_address:PORT. Example: proxy=123.123.123.123:3128. When you authenticate using login and password: loginparameters. Example: proxy=proxyuser:strongPassword@123.123.123.123:3128
  • proxytype – the type of proxy: HTTP, HTTPS, SOCKS4, SOCKS5. Example: proxytype=SOCKS4

Proxy and proxytype parameters are not set for work without proxy.

If captcha is already solved server will return the response in JSON. The response contains three values: challenge, validate and seccode:

To solve the geetest captcha you need to substitute values in the appropriate fields greatest_challenge, gee test_validate, geetest_seccode and click on button with text “Click to verify”.

Example of recognition GeeTest captcha in the Human Emulator program in php:

As a result of the example, a green check mark appears on the button “Click to verify”.

We have reviewed the most commonly used types of captcha. All types of captchas that can be recognized through the service https://2captcha.com and tariffs can be found on the website of the service.

If you need to add recognition of some type of captcha, which is not in the program write to us on the our forum.