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.

Record video in the Human Emulator

Record video in the Human Emulator Studio.

In the version of Human Emulator Studio 7.0.38, several interesting commands appeared that we would like to draw the attention of users to.

These are the start_video_record and stop_video_record commands added to two objects – windows and browser. Commands added to the object – windows – record video from a given area of the screen, commands added to the object – browser record video from a specified area of the browser.

How it works?

When you start recording video, the program performs the specified number of screenshots-frames per second with the specified quality, after which a file is created with the recording in avi format.

Description of the commands.

The start_video_record command accepts the following parameters:

path – full or relative path to the video file.
fps – is the number of frames per second. So with fps = 10, 10 frames per second will be done, and with fps = 30, 30 frames per second or 1 frame in 33 milliseconds. The optimal FPS value will depend on how quickly actions take place in the recorded area. To record normal browsing, fps = 10 will be enough. Default: 10.
quality – JPEG image quality. Maximum quality 100%. Image quality is understood as the amount of useful data that JPEG can save. Default: 70.
x – X coordinate of the upper left corner of the recorded area. Default: -1.
y – Y coordinate of the upper left corner of the recorded area. Default: -1.
width – the width of the recorded area. Default: -1.
height – the height of the recorded area. Default: -1.

With x = -1, y = -1, width = -1, height = -1 – the entire area of the screen or the built-in browser is recorded.

The stop_video_record command does not require any parameters. After calling this command, a record avi file will be created.

An example of use in php.

An example of a video recorded using start_video_record commands.

Using C # scripts in the Human Emulator

Using C # scripts in the Human Emulator.

There are two ways to work with a program using C # code.

  1. Writing scripts in C # in the program.
  2. Connecting separately written applications to the Human Emulator functionality.

Both methods use the XHE.dll library. The only differences are that when writing scripts in the program you do not need to connect the library, since it is already connected, and when creating separate projects you will need to connect this library.

XHE.dll library.

This dll library is a set of all objects and their functions that exist in the program.

A detailed description of the functionality of the objects can be found in our official documentation. The description for each function includes an example in C#.

The library was added to the program along with sources that are in the folder “folder with the program\Templates CSHARP\Lib\XHE\ XHE.sln“. The library sources are opened using Microsoft Visual Studio. If for some reason you need to make your changes to our library, you open the project in Microsoft Visual Studio, add your code there and then compile. The library connected to the Human Emulator is in the folder “folder with the program\Templates CSHARP\Lib\XHE\XHE\bin\Release\XHE.dll“. The main thing to note is that with the release of the new version, you will again have to reduce the library code, adding your changes to it. Whatever you do, you can send your code to us and we will add it to all subsequent versions of the program, but in this case your code will be available to all users of Human Emulator.

The library has been added to both “Human Emulator” (based on Internet Explorer) and “Human Emulator Studio” (based on Chromium) ranges. Work with the library in all versions of the program is completely identical. The differences are only in the available functionality.

Writing scripts in C # in a program.

To create a script in C # in the Human Emulator, just click on the File menu, point to New, and then click C# Script.

The “0.cs” script will open in the Scripts Editor with the following code:

The first part of the script is used to allow the use of types in the namespace.

The second part is the script itself. The InitXHE function is the entry point for every the Human Emulator objects. This function is called before using any program object. Without this call, you cannot work normally with it. After calling this function, work is going on with objects. In this case, it is browser.navigate(“google.ru”) and app.quit ();.
 
When the script is executed, it is compiled into EXE file and this EXE file is launched. Exe itself appears in the folder with the script and later it can be run as a regular EXE file. The main thing is that at the same time the Human Emulator would be opened. In it all the actions prescribed in EXE file will be performed.

Connecting third-party projects to the Human Emulator functionality.

In this case, you connect the xhe.dll library to your project just like any other.

After that, all objects and functions for controlling the Human Emulator become available in your project.