1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Demonstrates how to use EzCaptchaSolver to clear a DataDome challenge, both steps.
//!
//! **Task type:** [`DataDomeTaskProxyless`]
//!
//! The challenge takes two calls that share one solution model: step one returns
//! the challenge address in `url`, step two the validation instructions. Both run
//! through the synchronous endpoint.
//!
//! `referer` is what the service checks a site allow-list against, so leave it
//! set even though the parameter is not formally required.
//!
//! For detailed usage instructions, see the
//! [official EzCaptchaSolver documentation](https://docs.ezxlabs.com/docs/captcha/api).
use ezcapsolver::{AsyncEzCapSolverClient, DataDomeStep, DataDomeTask};
/// The interstitial or slider page, captured and base64-encoded.
const CHALLENGE_HTML_B64: &str = "base64_encoded_challenge_page";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = AsyncEzCapSolverClient::with_client_key("YOUR_API_KEY")?;
// Step one: find out where the challenge lives.
let first = client
.sync_solve_data_dome_task_proxyless(
&DataDomeTask::builder()
.html_b64(CHALLENGE_HTML_B64)
.step(DataDomeStep::One)
.referer("https://example.com")
.build(),
)
.await?
.solution;
println!("Kind: {}", first.kind.as_deref().unwrap_or("-"));
println!("Challenge: {}", first.url.as_deref().unwrap_or("-"));
// Fetch that page, capture the slider image, then ask for the validation
// instructions.
let second = client
.sync_solve_data_dome_task_proxyless(
&DataDomeTask::builder()
.html_b64(CHALLENGE_HTML_B64)
.step(DataDomeStep::Two)
.image("base64_encoded_slider_image")
.maybe_referer(first.url)
.build(),
)
.await?
.solution;
println!("Validate: {}", second.url.as_deref().unwrap_or("-"));
println!("Body: {}", second.body.as_deref().unwrap_or("-"));
println!("Balance: {}", client.balance().await?);
Ok(())
}