From dfe28a3cedd71963c06e855327b9283a55ff64d3 Mon Sep 17 00:00:00 2001 From: PBadicean Date: Tue, 23 Jan 2024 14:15:20 +0200 Subject: [PATCH] added friendly_captcha type (#14) --- README.md | 15 +++++++++++++-- README.ru.md | 14 ++++++++++++-- lib/api_2captcha/client.rb | 12 ++++++++---- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 11f51cf..8f6e212 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,9 @@ A Ruby client for the 2Captcha API. - [CyberSiARA](#cybersiara) - [DataDome](#datadome) - [MTCaptcha](#mtcaptcha) + - [Friendly captcha](#friendly-captcha) - [Other methods](#other-methods) - - [send / get_result](#send-get_result) + - [send / get_result](#send--get_result) - [balance](#balance) - [report](#report) - [Error handling](#error-handling) @@ -359,9 +360,19 @@ result = client.mt_captcha({ }) ``` +### Friendly captcha +Use this method to solve Friendly captcha and obtain a token to bypass the protection. +```ruby +result = client.friendly_captcha({ + pageurl: "https://example.com", + sitekey: "2FZFEVS1FZCGQ9" +}) +``` + ## Other methods -

send / get_result

+### send / get_result + These methods can be used for manual captcha submission and answer polling. ```ruby diff --git a/README.ru.md b/README.ru.md index 7db5fdd..6e1d055 100644 --- a/README.ru.md +++ b/README.ru.md @@ -28,8 +28,9 @@ Ruby-клиент для API 2Captcha. - [CyberSiARA](#cybersiara) - [DataDome](#datadome) - [MTCaptcha](#mtcaptcha) + - [Friendly captcha](#friendly-captcha) - [Другие методы](#other-methods) - - [send / get_result](#send-get_result) + - [send / get_result](#send--get_result) - [balance](#balance) - [report](#report) - [Обработка ошибок](#error-handling) @@ -316,9 +317,18 @@ result = client.mt_captcha({ }) ``` +### Friendly captcha +Метод решения Friendly captcha. Он возвращает токен для обхода капчи. +```ruby +result = client.friendly_captcha({ + pageurl: "https://example.com", + sitekey: "2FZFEVS1FZCGQ9" +}) +``` + ## Другие методы -

send / get_result

+### send / get_result Эти методы могут быть использованы для ручного отправления капчи и получения результата. ```ruby # пример для обычной капчи diff --git a/lib/api_2captcha/client.rb b/lib/api_2captcha/client.rb index faf5a01..5a5548c 100644 --- a/lib/api_2captcha/client.rb +++ b/lib/api_2captcha/client.rb @@ -10,20 +10,20 @@ class Client DEFAULT_DOMAIN = "2captcha.com" BASE_URL_FORMAT = "https://%s" - attr_reader :api_key, :soft_id - attr_accessor :domain, :callback, :default_timeout, :recaptcha_timeout, - :polling_interval + :polling_interval, + :api_key, :soft_id - def initialize(api_key, soft_id = 0, callback = nil) + def initialize(api_key, callback = nil) @api_key = api_key @soft_id = soft_id @callback = callback @default_timeout = 120 @recaptcha_timeout = 600 @polling_interval = 10 + @soft_id = 0 @domain = DEFAULT_DOMAIN end @@ -197,6 +197,10 @@ def mt_captcha(params) solve("mt_captcha", **params) end + def friendly(params) + solve("friendly_captcha", **params) + end + private def base_url