antiCaptcha

antiCaptcha ( string apiKey , string type , map options ) : string

Solve a captcha and return the solution or a key to pass the captcha.

How to use this API

You need to open an account on the API service to have the key.
Remember to go to the statistics to see what the current average bid is for captcha.
Then, it is advisable to carry over an appropriate bid into the API configuration afterwards. We recommend $5 / 1000 captcha.

Example


screenshot (x, y, height, width, path("tmp")+"imageCaptcha.png", 1)
response_captcha = antiCaptcha("72185299b356aa5fabf6da0e171c348d_example", "ImageToTextTask", ["path":path("tmp")+"imageCaptcha.png"])
firefox("javascript", """ document.getElementById('ca').value = "$response_captcha" """)
keyCaptcha=cleanSelect("[name=captcha_key]", codeSource, "value")
responseCaptcha=antiCaptcha(apiKey, "RecaptchaV2TaskProxyless", ["url":"https://www.mysite","key":keyCaptcha,"debug":true])
A more advanded example with an AntiGateTask personnel scheme for Darty
firefox("browse","https://www.darty.com/nav/achat/hifi_video/televiseurs-led/grand_ecran_led/tcl_55p735_2022.html") //test on a product page
firefox("waitLoaded")

iframeDatadome = cleanRegex(/(?si)<iframe [^<>]*src="([^<>"]+)"/, firefox("sourceCode"))
if(iframeDatadome)
{
firefox("browse",iframeDatadome)
firefox("waitLoaded")
sourceCodeIframe = firefox("sourceCode")

responseAntiCaptcha = null
iAntiCaptcha = 0
while(!responseAntiCaptcha)
{
responseAntiCaptcha = antiCaptcha("f5a79ffb52e0c4f9dda979c73e14b9be_example", "AntiGateTask", [
"url" : "https://www.darty.com/nav/achat/hifi_video/televiseurs-led/grand_ecran_led/tcl_55p735_2022.html",
"template" : "Darty", //the name of the modele found in the search model for Datadome (here WAIT_5_SECONDS and WAIT_SELECTOR_PRESENT on .offer-price)
"variables": [ ], //variable needed by this model in its documentation
"setCookie": true, //set the cookie in the Grimport cookie manager (not in firefox)
])
console(responseAntiCaptcha)

if(iAntiCaptcha>10)
{
console("More than 10 fails with AntiCaptcha")
stopAndClose()
}

iAntiCaptcha++
}

cookieAntiCaptcha = get(responseAntiCaptcha, 0)
firefox("setAllCookies", "https://www.darty.com/", cookieAntiCaptcha) //for firefox if needed
}
For a Datadome protection:
returnAntiCaptcha = null
while(!returnAntiCaptcha)
{
returnAntiCaptcha=antiCaptcha("325f34e8e12f9acb6b07050452090cda_example", "AntiGateTask", [
"url" : "https://www.somesite.de/",
"template" : "Anti-bot screen bypass", //the recommended model for Datadome
"variables" : ["css_selector" : ".captcha__human__container"],
"completeIdentificationFirefoxGrimport":true,
])
}


See also

universalCaptchaSolver

Parameters

apiKey

The api key in your anti-captcha account

type

There is sevral operation possibles with anti-captcha. You can use these ones:
  • RecaptchaV2TaskProxyless
  • RecaptchaV3TaskProxyless
  • ImageToTextTask
  • GeeTestTaskProxyless : it is for V3 of GeeTest. It returns an array [challenge, seccode, validate]
  • AntiGateTask : it returns an array [cookieValue, fingerprint, lastUrl, localStorage, apiResponseObject]

options

This argument depends on the type of operation. Ex: with RecaptchaV2TaskProxyless ["url":"http://makeawebsitehub.com/recaptcha/test.php", "key":"6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ"]
  • Commons parameters:
    • debug : display some messages to debug the function
  • for RecaptchaV2TaskProxyless
    • url : Address of a target web page. Can be located anywhere on the web site, even in a member area.
    • key : Recaptcha website key. Learn how to find it in this article.
    • dataS (optionnal) : Value of 'data-s' parameter. Applies only to Recaptchas on Google web sites.
  • for RecaptchaV3TaskProxyless
    • url : Address of a target web page. Can be located anywhere on the web site, even in a member area.
    • key : Recaptcha website key. Learn how to find it in this article.
    • action (optionnal) : Recaptcha's "action" value. Website owners use this parameter to define what users are doing on the page. Ex : grecaptcha.execute('site_key', {action:'login_test'})
    • minScoreWorker (optionnal, by default:0.3) : Workers are tested for their recaptcha "score" and put them in 3 groups (queues): 0.3, 0.7 and 0.9. Each might have slightly different pricing due to the number of idle workers. By passing property minScore you define which queue your task goes into. Most of our available workers have score 0.3, and the minority have 0.9.
  • for ImageToTextTask
    • path : path of the captcha image on your disk.
  • for GeeTestTaskProxyless
    • url : Address of a target web page. Can be located anywhere on the web site, even in a member area.
    • key : Recaptcha website key. Learn how to find it in this article.
    • challenge (optionnal) : Changing token key. Make sure you grab a fresh one for each captcha; otherwise, you'll be charged for an error task. Required for version 3. Not required for version 4
    • geetestApiServerSubdomain (optionnal) : Optional API subdomain. May be required for some implementations. See more.
    • geetestGetLib (optionnal) : Required for some implementations. Send the JSON encoded into a string. The value can be traced in browser developer tools. Put a breakpoint before calling the "initGeetest" function. See more.
  • for AntiGateTask
    • url : Address of a target web page.
    • template : the name of your model. You can find a model in the search tool or create your personnal model with this tutorial
    • . Note that a template you create must have a minimum of 60% success rate in its scenario. Otherwise it will be deactivated. This can be complex if the site blocks certain countries completely, as solvers will not be able to access the captcha to be solved. If you are unable to comply with the constraint, remove the check that the operation has been carried out correctly so that you always get positive feedback, and test the cookie returned in your program. In this way, you can manage the validation of the operation in your program rather than leaving it to AntiCaptcha.
    • variables : associative arrays of variables of your models (ex: ["cssSelector" : ".toto"]).
    • setCookie (optionnal) : boolean, default false, automatically set the cookie returned by the anti-captcha solver in the Grimport cookie manager if the application is a success.
    • setUserAgent (optionnal) : boolean, default false, automatically set the User Agent returned by the anti-captcha solver in the Grimport crawler if the application is a success.
    • setCookieFirefox (optionnal) : boolean, default false, automatically set the cookie returned by the anti-captcha solver in Firefox (by our extension) if the application is a success.
    • setLocalStorageFirefox (optionnal) : boolean, default false, automatically set the local storage returned by the anti-captcha solver in the local storage of Firefox if the application is a success.
    • setUserAgentFirefox (optionnal) : boolean, default false, automatically set the User Agent returned by the anti-captcha solver into Firefox if the application is a success.
    • completeIdentificationFirefoxGrimport (optionnal) : boolean, default false. This operation is equivalent to deleting the Firefox and Grimport cookies, followed by setCookieFirefox, setLocalStorageFirefox and setUserAgentFirefox, then the @url page is opened on Firefox and the Firefox cookies are copied to Grimport. This is a complete and very qualitative identification.
    Return value : a list containing [ the cookie value (string), an associative array for fingerprint, the last url seen by the anti-captcha solver, an associative array for its local storage, the object com.anti_captcha.ApiResponse.TaskResultResponse.SolutionData ]