Текстовая капча
Этот метод можно использовать для обхода задач, в которых вам нужно ответить на вопрос.
Вы можете добавить некоторый контекст, который поможет работникам дать ответ.
Спецификация для типа задачи TextCaptchaTask
Свойство | Тип | Обязателен | Описание |
---|---|---|---|
type | Строка | Да | Тип задачи: TextCaptchaTask |
comment | Строка | Да | Текст с вопросом, на который вам нужно ответить. |
Пример запроса
Метод: createTask
Эндпоинт API: https://api.2captcha.com/createTask
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "TextCaptchaTask",
"comment": "Если завтра суббота, то какой сегодня день?"
},
"languagePool": "rn"
}
Пример ответа
Метод: getTaskResult
Эндпоинт API: https://api.2captcha.com/getTaskResult
{
"errorId": 0,
"status": "ready",
"solution": {
"text": "пятница"
},
"cost": "0.001",
"ip": "1.2.3.4",
"createTime": 1692863536,
"endTime": 1692863556,
"solveCount": 1
}
Примеры кода
// https://github.com/2captcha/2captcha-php
require(__DIR__ . '/../src/autoloader.php');
$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');
try {
$result = $solver->text([
'text' => 'If tomorrow is Saturday, what day is today?',
'lang' => 'en',
]);
} catch (\Exception $e) {
die($e->getMessage());
}
die('Captcha solved: ' . $result->code);
# https://github.com/2captcha/2captcha-python
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
from twocaptcha import TwoCaptcha
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
solver = TwoCaptcha(api_key, defaultTimeout=40, pollingInterval=10)
try:
result = solver.text('If tomorrow is Saturday, what day is today?',
lang='en')
except Exception as e:
sys.exit(e)
else:
sys.exit('solved: ' + str(result))
// https://github.com/2captcha/2captcha-python
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
from twocaptcha import TwoCaptcha
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
solver = TwoCaptcha(api_key, defaultTimeout=40, pollingInterval=10)
try:
result = solver.text('If tomorrow is Saturday, what day is today?',
lang='en')
except Exception as e:
sys.exit(e)
else:
sys.exit('solved: ' + str(result))
// https://github.com/2captcha/2captcha-java
package examples;
import com.twocaptcha.TwoCaptcha;
import com.twocaptcha.captcha.Text;
public class TextExample {
public static void main(String[] args) {
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
Text captcha = new Text();
captcha.setText("If tomorrow is Saturday, what day is today?");
captcha.setLang("en");
try {
solver.solve(captcha);
System.out.println("Captcha solved: " + captcha.getCode());
} catch (Exception e) {
System.out.println("Error occurred: " + e.getMessage());
}
}
}
// https://github.com/2captcha/2captcha-go
package main
import (
"fmt"
"log"
"github.com/2captcha/2captcha-go"
)
func main() {
client := api2captcha.NewClient("API_KEY")
captcha := api2captcha.Text{
Text: "If tomorrow is Saturday, what day is today?",
Lang: "en",
}
code, err := client.Solve(captcha.ToRequest())
if err != nil {
log.Fatal(err);
}
fmt.Println("code "+code)
}
require 'api_2captcha'
client = Api2Captcha.new("YOUR_API_KEY")
result = client.text({
textcaptcha:'If tomorrow is Saturday, what day is today?',
lang: "en"
})