ImageToTextTask : حل رموز التحقق المصورة
ضف رموز تحقق مصورة واستخرج نصًا منها. يمكن أن يحتوي النص فقط على أرقام وأحرف وأحرف خاصة ومسافة. الرسوم المتحركة بتنسيق GIF مدعومة، حتى 500 كيلوبايت. لا يتم دعم اختبارات كابتشا المخصصة مثل "اعثر على قطة في مجموعة الصور هذه وادخل رقمها".
Task object
الخاصية | نوع الخاصية | الأهمية | القيمة الافتراضية | الوظيفة |
---|---|---|---|---|
type | String | مطلوبة | ImageToTextTask | برجاء تعيين نوع المهمة |
body | String | مطلوبة | نص الملف المشفر بنظام base64. تأكد من إرسال النص بدون فواصل أسطر. كذلك يرجى عدم ارسال (امتدادات مثل jpg أو png) أو علامات مشابهة، فقط نص مكتوب بترميز base64! | |
phrase | Boolean | غير مطلوبة | false | خطأ strong> - لا توجد متطلبات صحيح strong> - تتطلب من الموظف إدخال إجابة تحتوى على "مسافة " واحدة على الأقل. عليك اتباع التعليمات بحذر، فإذا لم تكن هناك مساحة سيقومون باستبعاد المهمة،. |
case | Boolean | غير مطلوبة | true | خطأ strong> - لا توجد متطلبات صحيح strong> - سيرى الموظف علامة خاصة تفيد بوجوب إدخال الإجابة بنص حساس لحالة الأحرف. |
numeric | Integer | غير مطلوبة | 0 | 0 - لا توجد متطلبات 1 - مسموح بالأرقام فقط 2 - يُسمح بأي أحرف باستثناء الأرقام |
math | Boolean | غير مطلوبة | false | خطأ strong> - لا توجد متطلبات صحيح strong> - سيرى الموظف علامة خاصة تفيد بوجوب حساب الإجابة |
minLength | Integer | غير مطلوبة | 0 | 0 - لا توجد متطلبات >1 - أقل طول مسموح به للإجابة |
maxLength | Integer | غير مطلوبة | 0 | 0 - لا توجد متطلبات >1 - أقصى طول مسموح به للإجابة |
comment | String | غير مطلوبة | تعليق إضافي للعمال مثل"ينبغي عليك إدخال النص باللون الأحمر". هذه النتيجة غير مضمونة وهي متروكة تمامًا للعامل. | |
websiteURL | String | غير مطلوبة | ميزة اختيارية لتمييز مصدر رموز التحقق من الصورة في احصائيات الإنفاق. |
مثال على الطلب
CURL
curl -i -H "Accept: application/json" \
-H "Content-Type: application/json" \
-X POST -d '{
"clientKey":"YOUR_API_KEY_HERE",
"task":
{
"type":"ImageToTextTask",
"body":"BASE64_BODY_HERE__NO_NEWLINES__NO_EXTRA_TAGS__ONLY_CLEAN_BASE64",
"phrase":false,
"case":false,
"numeric":0,
"math":false,
"minLength":0,
"maxLength":0
},
"softId": 0
}' https://api.anti-captcha.com/createTask
PHP
<?php
//git clone git@github.com:AdminAnticaptcha/anticaptcha-php.git
include("anticaptcha.php");
include("imagetotext.php");
$api = new ImageToText();
//your anti-captcha.com account key
$api->setKey("YOUR_API_KEY_HERE");
//setting file
$api->setFile("captcha.jpg");
//Specify softId to earn 10% commission with your app.
//Get your softId here: https://anti-captcha.com/clients/tools/devcenter
$api->setSoftId(0);
//create task in API
if (!$api->createTask()) {
echo "API v2 send failed - ".$api->getErrorMessage()."\n";
exit;
}
$taskId = $api->getTaskId();
if (!$api->waitForResult()) {
echo "could not solve captcha\n";
echo $api->getErrorMessage()."\n";
} else {
$captchaText = $api->getTaskSolution();
echo "captcha text: $captchaText\n\n";
}
Python
#pip3 install anticaptchaofficial
from anticaptchaofficial.imagecaptcha import *
solver = imagecaptcha()
solver.set_verbose(1)
solver.set_key("YOUR_API_KEY_HERE")
# Specify softId to earn 10% commission with your app.
# Get your softId here: https://anti-captcha.com/clients/tools/devcenter
solver.set_soft_id(0)
captcha_text = solver.solve_and_return_solution("captcha.jpeg")
if captcha_text != 0:
print "captcha text "+captcha_text
else:
print "task finished with error "+solver.error_code
NodeJS
//npm install @antiadmin/anticaptchaofficial
//https://github.com/AdminAnticaptcha/anticaptcha-npm
const ac = require("@antiadmin/anticaptchaofficial");
const fs = require('fs');
const captcha = fs.readFileSync('captcha.png', { encoding: 'base64' });
ac.setAPIKey('YOUR_API_KEY_HERE');
//Specify softId to earn 10% commission with your app.
//Get your softId here: https://anti-captcha.com/clients/tools/devcenter
ac.setSoftId(0);
ac.solveImage(captcha, true)
.then(text => console.log('captcha text: '+text))
.catch(error => console.log('test received error '+error));
C#
//git clone git@github.com:AdminAnticaptcha/anticaptcha-csharp
using System;
using Anticaptcha_example.Api;
using Anticaptcha_example.Helper;
using Newtonsoft.Json.Linq;
namespace Anticaptcha_example
{
internal class Program
{
private static void Main() {
DebugHelper.VerboseMode = true;
var api = new ImageToText
{
ClientKey = "YOUR_API_KEY_HERE",
FilePath = "captcha.jpg",
// Specify softId to earn 10% commission with your app.
// Get your softId here:
// https://anti-captcha.com/clients/tools/devcenter
SoftId = 0
};
if (!api.CreateTask())
DebugHelper.Out("API v2 send failed. " + api.ErrorMessage, DebugHelper.Type.Error);
else if (!api.WaitForResult())
DebugHelper.Out("Could not solve the captcha.", DebugHelper.Type.Error);
else
DebugHelper.Out("Result: " + api.GetTaskSolution().Text, DebugHelper.Type.Success);
}
}
}
Java
//git clone git@github.com:AdminAnticaptcha/anticaptcha-java.git
package com.anti_captcha;
import com.anti_captcha.Api.ImageToText;
import com.anti_captcha.Helper.DebugHelper;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.concurrent.ThreadLocalRandom;
public class Main {
public static void main(String[] args) throws InterruptedException, MalformedURLException, JSONException {
DebugHelper.setVerboseMode(true);
ImageToText api = new ImageToText();
api.setClientKey("YOUR_API_KEY_HERE");
api.setFilePath("captcha.jpg");
//Specify softId to earn 10% commission with your app.
//Get your softId here: https://anti-captcha.com/clients/tools/devcenter
api.setSoftId(0);
if (!api.createTask()) {
DebugHelper.out(
"API v2 send failed. " + api.getErrorMessage(),
DebugHelper.Type.ERROR
);
} else if (!api.waitForResult()) {
DebugHelper.out("Could not solve the captcha.", DebugHelper.Type.ERROR);
} else {
DebugHelper.out("Result: " + api.getTaskSolution().getText(), DebugHelper.Type.SUCCESS);
}
}
}
مثال على الاستجابة
كود JSON بدون أخطاء
{
"errorId": 0,
"taskId": 7654321
}
خطأ بكود JSON
{
"errorId": 1,
"errorCode": "ERROR_KEY_DOES_NOT_EXIST",
"errorDescription": "Account authorization key not found in the system"
}
الحصول على الحل
استخدم الطريقة getTaskResult لطلب الحل. امنح الموظف بعض الوقت، 5 ثوانٍ مثلًا، قبل تقديم الطلب الأول. إذا كان الموظف لا يزال مشغولاً، فينبغي عليك إعادةالمحاولة خلال 3 ثوانٍ.
حل المهمة
الخاصية | نوع الخاصية | الوظيفة |
---|---|---|
text | String | النص المستخرج من رموز تحقق المصورة |
url | String | عنوان الويب الخاص برمز التحقق كابتشا حيث سنقوم بتخزينه خلال الـ 24 ساعة القادمة. يتم إزالته بعد ذلك. |
مثال على الاستجابة
كود JSON بدون أخطاء
{
"errorId":0,
"status":"ready",
"solution":
{
"text":"deditur",
"url":"http://61.39.233.233/1/147220556452507.jpg"
},
"cost":"0.000700",
"ip":"46.98.54.221",
"createTime":1472205564,
"endTime":1472205570,
"solveCount":"0"
}