use std::time::Duration;
use ezcapsolver::{
AsyncEzCapSolverClient, ClientConfig, PollingConfig, TlsForwardTask, TlsHttpMethod::Get,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = ClientConfig::builder()
.timeout(Duration::from_secs(30))
.client_key("YOUR_API_KEY")
.polling(PollingConfig::new(Duration::from_secs(3), 10))
.build();
let client = AsyncEzCapSolverClient::with_config(config)?;
let task_payload = TlsForwardTask::builder()
.tls_type("chrome146")
.proxy(std::env::var("EZCAPTCHA_PROXY")?)
.method(Get)
.url("https://postman-echo.com/get")
.build();
match client.sync_solve_tls_task(&task_payload).await {
Ok(solution) => {
println!("solve success: {:?}", solution);
}
Err(ezcapsolver::Error::EzError(e)) => {
println!(
"EzCaptchaSolver error, task_id: {:?}, request_id: {:?}, errorCode: {:?}, errorDescription: {:?}, errors: {:?}",
e.task_id, e.request_id, e.error_code, e.error_description, e.errors
)
}
Err(e) => {
eprintln!("solve error: {:?}", e)
}
}
Ok(())
}