Capture Text from a Captcha Image
You can create a Network Library (.netx) file to capture a Captcha request from a webpage and store the content of that response. This will allow you to log into a webpage that has a Captcha challenge.
Process
Sample Files
captcha.netx
{
"validations": [],
"extractions": [
{
"name": "captcha",
"disabled": false,
"regex": ".*captcha.*",
"hint": "",
"method": "get",
"variable": "captcha",
"format": "http",
"target": "content",
"postprocessing": "/**You can add JavaScript code here.\n*\t\tUse standard functions to manipulate the extracted value.\n*\t\tThe extracted element is in variable value.\n**/\nreturn value;"
}
],
"mutations": []
}
anticaptcha.js
anticaptcha=(byteImage, apiKey)=>{
base64Capcha = encodeBase64(byteImage);
antiCapchaMessage = {
"clientKey":apiKey,
"task":
{
"type":"ImageToTextTask",
"body":base64Capcha,
"phrase":false,
"case":false,
"numeric":0,
"math":false,
"minLength":0,
"maxLength":0,
"languagePool":"en"
},
"softId": 0
}
taskId = JSON.parse(post("https://api.anti-captcha.com/createTask",antiCapchaMessage).toStringContent()).taskId;
taskResultMessage = {
"clientKey":apiKey,
"taskId":taskId
}
log(JSON.stringify(taskResultMessage));
for (;;){
var result = JSON.parse(post("https://api.anti-captcha.com/getTaskResult",taskResultMessage).toStringContent());
log(result)
if (result.status === "ready"){
return result.solution.text;
}
wait(1000);
}
}
var result = anticaptcha(locker.get("captchaImg"),locker.get("clientKey"))
locker.put("captchaSolution",result);
Last updated: October 02, 2024
If you have any feedback on this topic, please contact us at documentation@appvance.ai
