CAPTCHA

# Register with 2Captcha

Axiom does not provide a CAPTCHA solving service in house, but it is possible to integrate with third party captcha solving services.

To do this, you'll first need to register for the 2Captcha service: 2Captcha.com (opens new window)

# Add and configure the "Solve Captcha" sub-step

Add the "Solve Captcha" step in your automation.

The step is only able to solve the following widely used types of captcha:

  • reCAPTCHA v2
  • reCAPTCHA v3
  • invisible reCAPTCHA
  • hCaptcha
  • invisible hCaptcha

The step will take no action if a captcha is not present; if no captcha appears the automation will continue as normal, so it can be used for captchas that only appear intermittently without a problem.

Finally, enter the 2Captcha API key. This can be found in your settings page at 2Captcha.com: 2Captcha settings page (opens new window)

# About 2Captcha

2Captcha only charges for successfully solved captchas.

The captcha solving process takes around 30-60 seconds each time it is required; the captchas are being solved by humans.

The service is not infallible - it cannot solve custom captcha implementations, and can sometimes fail if the captcha is solved incorrectly at 2Captcha's end.

# Solving other types of captcha

Although the "Solve Captcha" step only supports the previously mentioned styles of captcha 2Captcha provides an API that Axiom can integrate with to solve other types of captcha. Full details of all the styles of captchas that 2Captcha support along with the API documentation can be found in the 2Captcha API documentation (opens new window)

You will need to use a custom Javascript step to interact with the 2Captcha API Using Javascript with Axiom documentation (opens new window)

Here's an example script that solves an image to text style captcha, please note this script uses the Puppeteer API (opens new window)

const apiKey = 'XXX' // Your 2Captcha API key goes here
const ele = await page.$('#captcha_image') // The selector for the captcha image goes here

const base64 = await ele.screenshot({encoding: 'base64'})
const delay = ms => new Promise(res => setTimeout(res, ms))

// Set up 2captcha API call
let options = {
  'clientKey': apiKey,
  'task': {
    'type': 'ImageToTextTask',
    'body': base64,
    'case': true
  },
  'languagePool': 'en'
}


// Post to 2Captcha API and get the id for of the request
let postData = {method: 'POST', body: JSON.stringify(options)}
let response = await fetch('https://api.2captcha.com/createTask', postData)
let json = await response.json()
const taskId = json.taskId

// Try and get the solution every 20 seconds
do {
  await delay(20000)
  postData = {method: 'POST', body: JSON.stringify({'clientKey': apiKey, 'taskId': taskId})}
  response = await fetch('https://api.2captcha.com/getTaskResult', postData)
  json = await response.json()
} while (json.status && json.status === 'processing')

 return [[json.solution.text]]

The script will return the solution to the captcha which can then be input into the form with an 'Enter Text' step