Skip to main content

ezcapsolver/tasks/
hcaptcha.rs

1use serde::Serialize;
2
3use super::ExtraFields;
4
5/// HCaptcha token task.
6#[derive(Debug, Clone, Serialize, Default, bon::Builder)]
7#[builder(on(String, into))]
8#[serde(remote = "Self", rename_all = "camelCase")]
9pub struct HcaptchaTask {
10    /// URL of the page containing the challenge.
11    #[serde(rename = "websiteURL")]
12    pub website_url: String,
13    /// HCaptcha site key.
14    pub website_key: String,
15    /// Browser language. Only `en-US` is supported at the moment.
16    pub lang: String,
17    /// Optional proxy forwarded to the worker.
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub proxy: Option<String>,
20    /// Whether the challenge runs without a visible checkbox.
21    ///
22    /// True when the site shows no hCaptcha checkbox, false when it does.
23    pub invisible: bool,
24    /// Optional `rqdata` value, required by the sites that publish one.
25    ///
26    /// The wire name is all lowercase here, unlike the Cloudflare types, whose
27    /// equivalent field is `rqData`. The two are not interchangeable.
28    #[serde(rename = "rqdata", skip_serializing_if = "Option::is_none")]
29    pub rq_data: Option<String>,
30    /// Additional worker parameters.
31    #[serde(skip)]
32    #[builder(default)]
33    pub extra: ExtraFields,
34}
35
36/// HCaptcha image classification task.
37#[derive(Debug, Clone, Serialize, Default, bon::Builder)]
38#[builder(on(String, into))]
39#[serde(remote = "Self", rename_all = "camelCase")]
40pub struct HcaptchaClassificationTask {
41    /// Optional single image.
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub image: Option<String>,
44    /// Optional image collection.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub images: Option<Vec<String>>,
47    /// Optional anchor collection.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub anchors: Option<Vec<String>>,
50    /// Optional classification question.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub question: Option<String>,
53    /// Optional classification module.
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub module: Option<String>,
56    /// Additional worker parameters.
57    #[serde(skip)]
58    #[builder(default)]
59    pub extra: ExtraFields,
60}