Skip to content

Anticaptcha Actions

Anticaptcha actions easily integrates Marvin with Anti-Captcha service. To use this service is required to be anticaptcha user and have a valid anticaptcha account key.

Actions

anticaptcha.hcaptcha

This action solves hCaptchas, on the current page and no further action at captchas should be done.

To use it just call this action on script, given the correct browser object with a page that has hCaptcha on it, and wait for captcha solving.

Callback can be validated in two different ways: POST or callback function.

If the page you are automating use the POST method to validate ReCaptcha, just call the anticaptcha.hcaptcha action passing your anticapthca_key, you don't need to pass the callback_function.

If the page uses the callback function, you should pass as parameter your anticaptcha_key and the name of callback_function used. To identify the callback function, you can have further information here

Important: the ReCaptcha solution is valid for maximum 2 minutes, so it is important to solve captcha as the last action before page submit, otherwise the validation could be lost.

Parameters:

browser - browser object with the page that has the captcha on it

anticaptcha_key - Anti-Captcha Account Key, to identify your account and credits at Anti-Captcha.

callback_function (optional) - Set the name of callback function to call after hCaptcha change is done.

hcaptcha_key (optional) - allow to specify page hcaptcha key if Marvin could not find it automatically.

Returns:

This action gives no return

Exceptions:

CaptchaNotFound: if it is not possible to identify the ReCaptcha V2 on the given page.

anticaptcha.image_captcha

This action solves image catpcha found on screen.

Parameters:

anticaptcha_key - Anti-Captcha Account Key, to identify your account and credits at Anti-Captcha.

img_file - file containing the captcha picture to be solved

Returns:

captcha - text with captcha solution

Exceptions:

CaptchaNotFound: if it is not possible to solve captcha image

anticaptcha.recaptcha_v2

This action solves ReCaptchas in Version 2, on the current page and no further action at captchas should be done.

To use it just call this action on script, given the correct browser object with a page that has ReCaptcha V2 on it, and wait for captcha solving.

Callback can be validated in two different ways: POST or callback function.

If the page you are automating use the POST method to validate ReCaptcha, just call the anticaptcha.recaptcha_v2 action passing your anticapthca_key, you don't need to pass the callback_function.

If the page uses the callback function, you should pass as parameter your anticaptcha_key and the name of callback_function used. To identify the callback function, you can have further information here

Important: the ReCaptcha solution is valid for maximum 2 minutes, so it is important to solve captcha as the last action before page submit, otherwise the validation could be lost.

Parameters:

browser - browser object with the page that has the captcha on it

anticaptcha_key - Anti-Captcha Account Key, to identify your account and credits at Anti-Captcha.

callback_function - Set the name of callback function to call after ReCaptcha change is done.

Returns:

This action gives no return

Exceptions:

CaptchaNotFound: if it is not possible to identify the ReCaptcha V2 on the given page.

How to get ReCaptcha callback function

The ReCaptcha callback function could be found in two different ways: as a HTML element or programatically.

To use the HTML element callback, it is needed to includ the g-recaptcha class inside a element (usually a input or a div). The callback function is defined as data-callback parameter, and the tag must have the data-sitekey defined also, as the example defines the loginFn as callback function:

<input type="submit" class="g-recaptcha" data-callback="loginFn" onclick="validateForm" value="OK" data-sitekey="XXXXXXXXXXXXXXXXXXXXXXXX">

The programatically callback definition, is done on grecaptcha.render method call, passing the callback parameter passing the callback function, as the example defines the verifyCallbackCaptcha as callback function:

grecaptcha.render("recaptcha", {
    "sitekey": "XXXXXXXXXXXXXXXXXXXXXXXX",
    "callback": verifyCallbackCaptcha,
    "size": "invisible"
})