pub struct ImageCaptcha {
pub captcha_interface: CaptchaInterface,
}
Expand description
Captcha solving method - ImageToTextTask
and ImageToCoordinatesTask
§Examples
With already prepared base64 string
use serde_json::json;
use rust_anticaptcha::core::enums::ImageTaskType;
use rust_anticaptcha::image_captcha::ImageCaptcha;
async fn run() {
let map = json!({"body": "base64_string"});
let mut image_to_text_client = ImageCaptcha::new("API_KEY".to_string());
image_to_text_client.captcha_handler(ImageTaskType::ImageToCoordinatesTask, &map).await;
}
With image as file
use serde_json::json;
use rust_anticaptcha::core::enums::ImageTaskType;
use rust_anticaptcha::image_captcha::ImageCaptcha;
use rust_anticaptcha::instruments::image_instrument::ImageInstrument;
async fn run() {
let image_instrument = ImageInstrument::new();
let image_file_base64 = image_instrument.read_image_file("files/captcha-image.jpg".to_string());
let map = json!({"body": image_file_base64});
let mut image_to_text_client = ImageCaptcha::new("API_KEY".to_string());
image_to_text_client.captcha_handler(ImageTaskType::ImageToTextTask, &map).await;
}
With image as link
use serde_json::json;
use rust_anticaptcha::core::enums::ImageTaskType;
use rust_anticaptcha::image_captcha::ImageCaptcha;
use rust_anticaptcha::instruments::image_instrument::ImageInstrument;
async fn run() {
let image_instrument = ImageInstrument::new();
let image_link_base64 = image_instrument.read_image_link("https://captcha-image.jpg".to_string()).await;
let map = json!({"body": image_link_base64});
let mut image_to_text_client = ImageCaptcha::new("API_KEY".to_string());
image_to_text_client.captcha_handler(ImageTaskType::ImageToTextTask, &map).await;
}
§Notes
Read more here:
https://anti-captcha.com/apidoc/task-types/ImageToTextTask
https://anti-captcha.com/apidoc/task-types/ImageToCoordinatesTask
Fields§
§captcha_interface: CaptchaInterface
Implementations§
Source§impl ImageCaptcha
impl ImageCaptcha
Sourcepub async fn captcha_handler(
&mut self,
captcha_type: ImageTaskType,
task_payload: &Value,
) -> Value
pub async fn captcha_handler( &mut self, captcha_type: ImageTaskType, task_payload: &Value, ) -> Value
Method run captcha solving logic
§Arguments
captcha_type
- One of image captcha types from ImageTaskType
task_payload
- JSON with captcha task payload
§Examples
use serde_json::json;
use rust_anticaptcha::core::enums::ImageTaskType;
use rust_anticaptcha::image_captcha::ImageCaptcha;
async fn run() {
let map = json!({"body": "base64_string"});
let mut image_to_text_client = ImageCaptcha::new("API_KEY".to_string());
image_to_text_client.captcha_handler(ImageTaskType::ImageToTextTask, &map).await;
}
Auto Trait Implementations§
impl Freeze for ImageCaptcha
impl !RefUnwindSafe for ImageCaptcha
impl Send for ImageCaptcha
impl Sync for ImageCaptcha
impl Unpin for ImageCaptcha
impl !UnwindSafe for ImageCaptcha
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more