문서 튜토리얼 로그인
지원되는 태스크 유형
API 메소드
기사
튜토리얼
GitHub
문서 메뉴

ImageToTextTask : 이미지 캡챠를 푸세요.

Post an image body and receive text from it. 텍스트에는 숫자, 문자, 특수 문자, 여백만 포함될 수 있습니다. GIF 애니메이션은 최대 500kb 지원됩니다. "이 이미지 세트에서 고양이를 찾고 번호를 입력하세요."와 같은 맞춤형 캡챠는 지원되지 않습니다.

태스크 객체

프로퍼티 유형 필수 기본값 목적
type 스트링 ImageToTextTask 태스크 유형을 규정하세요.
body 스트링 파일 본문 base64로 인코딩됨. 줄바꿈 없이 전송하세요. 'data:image/png,' 혹은 유사한 태그를 포함하지 마세요. 말끔한 base64만 이용하세요!
phrase 불린 아니요 false false - 필수 요건 없음
true - 작업자가 최소 한 개의 "여백"으로 답변을 입력해야 함. 여백이 없는 경우, 태스크를 넘기므로 주의해서 이용해야 합니다.
case 불린 아니요 true false - 필수 요건 없음
true - 작업자는 대소문자를 구별하여 답을 입력해야 한다는 특별 표시를 보게 될 것입니다.
numeric 정수 아니요 0 0 - 필수 요건 없음
1 - 숫자만 허용됨
2 - 숫자를 제외한 모든 문자 허용됨
math 불린 아니요 false false - 필수 요건 없음
true - 작업자는 답이 계산되어야 한다는 특별 표시를 보게 될 것입니다.
minLength 정수 아니요 0 0 - 필수 요건 없음
>1 - 최소 답변 길이를 규정하세요.
maxLength 정수 아니요 0 0 - 필수 요건 없음
>1 - 최대 답변 길이를 규정하세요.
comment 스트링 아니요 "빨간색으로 문자를 입력하세요."와 같은 작업자에게 전하는 추가 코멘트.
결과는 보장되지 않으며 완전히 작업자에게 달려 있습니다.
websiteURL 스트링 아니요 지출 통계에서 이미지 캡챠의 출처를 구분하는 선택적인 매개변수

예시 요청

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 스트링 이미지 캡챠의 텍스트
url 스트링 저희가 향후 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"
}