ImageToTextTask : किसी इमेज कैप्चा को हल करें
कोई इमेज बॉडी पोस्ट करके उससे टेक्स्ट प्राप्त करें। टेक्स्ट में केवल अंक, अक्षर, ख़ास करैक्टर व एक स्पेस ही हो सकता है। 500 kb तक की GIF एनीमेशनें भी मान्य होती हैं। "इस इमेज सेट में एक बिल्ली ढूँढकर उसका नंबर एंटर करें" जैसे कस्टम कैप्चा सपोर्ट नहीं किए जाते।
टास्क ऑब्जेक्ट
प्रॉपर्टी | टाइप | आवश्यक | डिफ़ॉल्ट मान | लक्ष्य |
---|---|---|---|---|
type | स्ट्रिंग | हाँ | ImageToTextTask | यह इस बात को परिभाषित करता है कि टास्क किस प्रकार की है। |
body | स्ट्रिंग | हाँ | फाइल बॉडी base64 में एनकोडेड है। कृपया इसे बिना किसी लाइन ब्रेक के ही भेजें। 'data:image/png’ या उससे मिलते-जुलते टैग इसमें शामिल ना करें, केवल क्लीन base64 ही करें! | |
phrase | Boolean | नहीं | false | गलत - सही कोई आवश्यकता नहीं - कर्मचारी को कम से कम एक "स्पेस" वाला जवाब एंटर करना होता है। कोई स्पेस ना होने पर टास्क स्किप हो जाएगी, तो इसका इस्तेमाल ध्यान से करें। |
case | Boolean | नहीं | true | गलत - सही कोई आवश्यकता नहीं – कर्मचारी को यह बताने वाला एक ख़ास चिह्न दिखाई दे जाएगा कि जवाब दर्ज करते समय केस सेंसिटिविटी का ध्यान रखना चाहिए। |
numeric | इन्टिजर | नहीं | 0 | 0 - 1 कोई आवश्यकता नहीं - 2 - संख्याओं के अलावा सभी अक्षर मान्य |
math | Boolean | नहीं | false | गलत - सही कोई आवश्यकता नहीं – कर्मचारी को यह बताने वाला एक ख़ास चिह्न दिखाई दे जाएगा कि उत्तर का हिसाब लगाया जाना चाहिए। |
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"
}