Skip to content

Commit 13b6949

Browse files
committed
UPDATE: updated for latest version compability
1 parent 33377a4 commit 13b6949

20 files changed

+165
-99
lines changed

CapSolver.Tests/BaseMethodTests.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ public async void TestBalance()
77
{
88
var client = new CapSolverClient(Environment.GetEnvironmentVariable("APIKEY")!, false);
99
float balance = await client.GetBalance();
10-
Assert.NotNull(balance);
1110
Assert.IsType<float>(balance);
12-
Assert.True(default (float) != balance);
11+
Assert.True(default != balance);
1312
}
1413

1514
[Fact]

CapSolver.Tests/FunCaptchaTaskTest.cs

-19
This file was deleted.

CapSolver/CapSolverClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public async Task<string> CreateTask(ITask task)
9090
{
9191
JObject vt = JObject.FromObject(t);
9292
JObject t_ = JObject.FromObject(task);
93-
t_["type"] += "Proxyless";
93+
t_["type"] += "ProxyLess";
9494
vt["task"] = t_;
9595
data = vt.ToString();
9696
}

CapSolver/Models/Responses/DatadomeSliderResponse.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ namespace CapSolver.Models.Responses;
55

66
public class DatadomeSliderResponse : ITaskResponse
77
{
8-
[JsonRequired]
98
[JsonProperty("cookie")]
10-
public string Cookie { get; set; } = null!;
9+
public string Cookie { get; set; }
10+
11+
[JsonRequired]
12+
[JsonProperty("userAgent")]
13+
public string UserAgent { get; set; } = null!;
1114
}

CapSolver/Models/Responses/GeeTestResponse.cs

-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,4 @@ public class GeeTestResponse : ITaskResponse
1212
[JsonRequired]
1313
[JsonProperty("validate")]
1414
public string Validate { get; set; } = null!;
15-
16-
[JsonRequired]
17-
[JsonProperty("seccode")]
18-
public string SecCode { get; set; } = null!;
1915
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Newtonsoft.Json;
2+
3+
namespace CapSolver.Models.Responses;
4+
5+
public class GeeTestV4Response
6+
{
7+
[JsonProperty("captcha_id")]
8+
public string CaptchaId { get; set; }
9+
10+
[JsonProperty("captcha_output")]
11+
public string CaptchaOutput { get; set; }
12+
13+
[JsonProperty("gen_time")]
14+
public string GenTime { get; set; }
15+
16+
[JsonProperty("lot_number")]
17+
public string LotNumber { get; set; }
18+
19+
[JsonProperty("pass_token")]
20+
public string Token { get; set; }
21+
22+
[JsonProperty("risk_type")]
23+
public string RiskType { get; set; }
24+
25+
}

CapSolver/Models/Responses/HCaptchaClassificationResponse.cs

+6
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@ public class HCaptchaClassificationResponse : ITaskResponse
88
[JsonRequired]
99
[JsonProperty("objects")]
1010
public IList<bool> Objects { get; set; } = null!;
11+
12+
[JsonProperty("box")]
13+
public IList<float>? Box { get; set; }
14+
15+
[JsonProperty("imageSize")]
16+
public Tuple<int, int> ImageSize { get; set; }
1117
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
using CapSolver.Utilities;
2+
using Newtonsoft.Json;
23

34
namespace CapSolver.Models.Responses;
45

5-
public class HCaptchaTaskResponse : ReCaptchaV2Response, ITaskResponse { }
6+
public class HCaptchaTaskResponse : ReCaptchaV2Response, ITaskResponse
7+
{
8+
[JsonRequired]
9+
[JsonProperty("timestamp")]
10+
public long Timestamp { get; set; }
11+
12+
[JsonRequired]
13+
[JsonProperty("captchaKey")]
14+
public string CaptchaKey { get; set; } = null!;
15+
}

CapSolver/Models/Responses/MtCaptchaResponse.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ namespace CapSolver.Models.Responses;
55

66
public class MtCaptchaResponse : ITaskResponse
77
{
8-
[JsonRequired]
98
[JsonProperty("token")]
10-
public string Token { get; set; } = null!;
9+
public string Token { get; set; }
10+
11+
[JsonProperty("userAgent")]
12+
public string UserAgent { get; set; }
1113
}

CapSolver/Models/Responses/ReCaptchaV2Response.cs

+6
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@ public class ReCaptchaV2Response : ITaskResponse
88
[JsonRequired]
99
[JsonProperty("gRecaptchaResponse")]
1010
public string GReCaptchaResponse { get; set; } = null!;
11+
12+
[JsonProperty("userAgent")]
13+
public string UserAgent { get; set; } = null!;
14+
15+
[JsonProperty("expireTime")]
16+
public long ExpireTime { get; set; }
1117
}

CapSolver/Models/Responses/ReCaptchaV3Response.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
namespace CapSolver.Models.Responses;
44

5-
public class ReCaptchaV3Response : ReCaptchaV2Response, ITaskResponse { }
5+
public class ReCaptchaV3Response : ReCaptchaV2Response, ITaskResponse
6+
{
7+
8+
}

CapSolver/Tasks/AwsWafClassificationTask.cs

+4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ public class AwsWafClassificationTask : ITask
1717

1818
/// <summary>
1919
/// For full names of questions, please refer to the following list of questions.
20+
/// <br />
21+
/// See question allow list: <seealso href="https://docs.capsolver.com/guide/recognition/AwsWafClassification.html#create-task">click here</seealso>
2022
/// </summary>
2123
[JsonProperty("question", NullValueHandling = NullValueHandling.Include)]
2224
public string Question { get; set; }
2325

2426
/// <summary>
2527
/// Prepare a AwsWafClassification task.
28+
/// <br/>
29+
/// See supported types: <seealso href="https://docs.capsolver.com/guide/recognition/AwsWafClassification.html#support-types">click here</seealso>
2630
/// </summary>
2731
/// <param name="images">Base64-encoded images, do not include "data:image/***;base64,"Base64-encoded images, do not include "data:image/***;base64,"</param>
2832
/// <param name="question">For full names of questions, please refer to the following list of questions.</param>

CapSolver/Tasks/FunCaptchaClassification.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ public class FunCaptchaClassification : ITask
2323
/// Only support English requires accurate case, other languages please convert to English yourself
2424
/// The server will automatically determine different image types according to the question, so please make sure the question is correct.
2525
/// Please see the list at the end of the document for the full list of image types and corresponding English questions
26+
/// <br/>
27+
/// See the supported question list: <seealso href="https://docs.capsolver.com/guide/recognition/FunCaptchaClassification.html#create-task">click here</seealso>
2628
/// </summary>
2729
[JsonRequired]
2830
[JsonProperty("question")]
2931
public string Question { get; set; }
3032

3133
/// <summary>
3234
/// Prepare a FunCaptchaClassification task.
35+
/// <br/>
36+
/// See supported types of FunCaptcha: <seealso href="https://docs.capsolver.com/guide/recognition/FunCaptchaClassification.html#supported-types">click here</seealso>
3337
/// </summary>
3438
/// <param name="image">Base64 encoded image, can be a screenshot (pass only the hexagonal image, do not pass the rest of the content)</param>
35-
/// <param name="question">Question name. Pass the full name, such as: Pick the lion. Only support English requires accurate case, other languages please convert to English yourself</param>
39+
/// <param name="question">Question name. Pass the full name, such as: Pick the lion. Only support English requires accurate case, other languages please convert to English yourself.<br/>See the supported question list: <seealso href="https://docs.capsolver.com/guide/recognition/FunCaptchaClassification.html#create-task">click here</seealso></param>
3640
public FunCaptchaClassification(string image, string question)
3741
{
3842
Image = image;

CapSolver/Tasks/FunCaptchaTask.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class FunCaptchaTask : ITask, IProxyTask, IUserAgentTask
2727
/// A special subdomain of funcaptcha.com, from which the JS captcha widget should be loaded. Most FunCaptcha installations work from shared domains.
2828
/// </summary>
2929
[JsonProperty("funcaptchaApiJSSubdomain")]
30-
public string ApiJsSubdomain { get; set; }
30+
public string? ApiJsSubdomain { get; set; }
3131

3232
/// <summary>
3333
/// Additional parameter that may be required by FunCaptcha implementation. Use this property to send "blob" value as a stringified array. See example how it may look like.
@@ -51,7 +51,7 @@ public class FunCaptchaTask : ITask, IProxyTask, IUserAgentTask
5151
/// <param name="data">Additional parameter that may be required by FunCaptcha implementation. Use this property to send "blob" value as a stringified array. See example how it may look like. </param>
5252
public FunCaptchaTask(string websiteUrl,
5353
string websitePublicKey,
54-
string apiJsSubdomain,
54+
string? apiJsSubdomain = null,
5555
string? data = null,
5656
string? userAgent = null)
5757
{

CapSolver/Tasks/GeeTestTask.cs

+17-46
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace CapSolver.Tasks;
99
public class GeeTestTask : ITask, IProxyTask, IUserAgentTask, ICookieTask
1010
{
1111
[JsonProperty("type")]
12-
private readonly string Type = "GeetestTask";
12+
private readonly string Type = "GeeTestTask";
1313

1414
/// <summary>
1515
/// Address of a webpage with Geetest
@@ -19,83 +19,54 @@ public class GeeTestTask : ITask, IProxyTask, IUserAgentTask, ICookieTask
1919
/// <summary>
2020
/// The domain public key, rarely updated.
2121
/// </summary>
22-
[JsonRequired]
23-
[JsonProperty("gt")]
24-
public string Gt { get; set; }
22+
[JsonProperty("gt", NullValueHandling = NullValueHandling.Ignore)]
23+
public string? Gt { get; set; }
2524

2625
/// <summary>
2726
/// Changing token key. Make sure you grab a fresh one for each captcha; otherwise, you'll be charged for an error task.
2827
/// </summary>
29-
[JsonRequired]
30-
[JsonProperty("challenge")]
31-
public string Challenge { get; set; }
28+
[JsonProperty("challenge", NullValueHandling = NullValueHandling.Ignore)]
29+
public string? Challenge { get; set; }
30+
31+
[JsonProperty("captchaId")]
32+
public string? CaptchaId { get; set; }
3233

3334
/// <summary>
3435
/// Optional API subdomain. May be required for some implementations.
3536
/// </summary>
3637
[JsonProperty("geetestApiServerSubdomain", NullValueHandling = NullValueHandling.Ignore)]
3738
public string? ApiServerSubdomain { get; set; }
38-
39-
/// <summary>
40-
/// Required for some implementations. Send the JSON encoded into a string. The value can be traced in browser developer tools. Put a breakpoint before calling the "initGeetest" function.
41-
/// </summary>
42-
[JsonProperty("geetestGetLib", NullValueHandling = NullValueHandling.Ignore)]
43-
public string? GeeTestGetLib { get; set; }
44-
45-
/// <summary>
46-
/// Version number. Default version is 3.
47-
/// </summary>
48-
[JsonProperty("version", NullValueHandling = NullValueHandling.Ignore)]
49-
public string? Version { get; set; }
50-
51-
/// <summary>
52-
/// Additional initialization parameters for version 4
53-
/// </summary>
54-
[JsonProperty("initParameters", NullValueHandling = NullValueHandling.Ignore)]
55-
public string? InitParameters { get; set; }
5639

5740
/// <summary>
5841
/// Browser's User-Agent which is used in emulation. It is required that you use a signature of a modern browser, otherwise Google will ask you to "update your browser".
5942
/// </summary>
6043
[JsonProperty("userAgent", NullValueHandling = NullValueHandling.Ignore)]
6144
public string? UserAgent { get; set; }
6245

63-
/// <summary>
64-
/// Additional cookies which we must use during interaction with target page or Google.
65-
/// </summary>
66-
[JsonProperty("cookies", NullValueHandling = NullValueHandling.Ignore)]
67-
public string? Cookies { get; set; }
68-
6946
/// <summary>
7047
/// Preapre a GeeTest task
7148
/// </summary>
7249
/// <param name="websiteUrl">Address of a webpage with Geetest</param>
7350
/// <param name="gt">The domain public key, rarely updated.</param>
7451
/// <param name="challenge">Changing token key. Make sure you grab a fresh one for each captcha; otherwise, you'll be charged for an error task.</param>
7552
/// <param name="apiServerSubdomain">Optional API subdomain. May be required for some implementations.</param>
76-
/// <param name="getLib">Required for some implementations. Send the JSON encoded into a string. The value can be traced in browser developer tools. Put a breakpoint before calling the "initGeetest" function.</param>
77-
/// <param name="version">Version number. Default version is 3.</param>
78-
/// <param name="initParameters">Additional initialization parameters for version 4</param>
79-
/// <param name="cookies">Additional cookies which we must use during interaction with target page or Google.</param>
8053
/// <param name="userAgent">Browser's User-Agent which is used in emulation.</param>
8154
public GeeTestTask(string websiteUrl,
82-
string gt,
83-
string challenge,
55+
string? gt = null,
56+
string? challenge = null,
8457
string? apiServerSubdomain = null,
85-
string? getLib = null,
86-
string? version = null,
87-
string? initParameters = null,
88-
string? cookies = null,
89-
string? userAgent = null)
58+
string? userAgent = null,
59+
string? captchaId = null)
9060
{
9161
WebsiteURL = websiteUrl;
9262
Gt = gt;
9363
Challenge = challenge;
9464
ApiServerSubdomain = apiServerSubdomain;
95-
GeeTestGetLib = getLib;
96-
Version = version;
97-
InitParameters = initParameters;
9865
UserAgent = userAgent;
99-
Cookies = cookies;
66+
CaptchaId = captchaId;
67+
if (gt != null && challenge != null)
68+
{
69+
CaptchaId = null;
70+
}
10071
}
10172
}

CapSolver/Tasks/HCaptchaTask.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ public class HCaptchaTask : ITask, IProxyTask, IUserAgentTask
3131
[JsonProperty("enterprisePayload", NullValueHandling = NullValueHandling.Ignore)]
3232
public object? EnterprisePayload { get; set; }
3333

34-
/// <summary>
35-
/// Use true for enterprise version of hcaptcha
36-
/// </summary>
37-
[JsonProperty("isEnterprise", NullValueHandling = NullValueHandling.Ignore)]
38-
public bool? IsEnterprise { get; set; }
39-
4034
/// <summary>
4135
/// Use true for invisible version of hcaptcha
4236
/// </summary>
@@ -57,6 +51,7 @@ public class HCaptchaTask : ITask, IProxyTask, IUserAgentTask
5751
/// <param name="enterprisePayload">Custom data that is used in some implementations of hCaptcha Enterprise. So you need to put true in the isEnterprise parameter. In most cases you see it as rqdata inside network requests. IMPORTANT: you MUST provide userAgent if you submit captcha with data parameter. The value should match the User-Agent you use when interacting with the target website.</param>
5852
/// <param name="isEnterprise">Use true for enterprise version of hcaptcha</param>
5953
/// <param name="isInvisible">Use true for invisible version of hcaptcha</param>
54+
/// <param name="userAgent">Browser's User-Agent which is used in emulation.</param>
6055
public HCaptchaTask(string websiteUrl,
6156
string websiteKey,
6257
object? enterprisePayload = null,
@@ -67,8 +62,11 @@ public HCaptchaTask(string websiteUrl,
6762
WebsiteURL = websiteUrl;
6863
WebsiteKey = websiteKey;
6964
EnterprisePayload = enterprisePayload;
70-
IsEnterprise = isEnterprise;
7165
IsInvisible = isInvisible;
7266
UserAgent = userAgent;
67+
if (isEnterprise == true)
68+
{
69+
Type = "HCaptchaEnterpriseTask";
70+
}
7371
}
7472
}

CapSolver/Tasks/ImageToTextTask.cs

+23-1
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,34 @@ public class ImageToTextTask : ITask
2020
[JsonProperty("body")]
2121
public string Body { get; set; }
2222

23+
/// <summary>
24+
/// Specifies the module. Currently, the supported modules are common and queueit.
25+
/// </summary>
26+
[JsonProperty("module")]
27+
public string? Module { get; set; }
28+
29+
/// <summary>
30+
/// Identify the matching degree. If the recognition rate is not within the range, no deduction
31+
/// </summary>
32+
/// <value>0.8 ~ 1</value>
33+
[JsonProperty("score")]
34+
public float? Score { get; set; }
35+
36+
/// <summary>
37+
/// Case sensitive or not
38+
/// </summary>
39+
[JsonProperty("case")]
40+
public bool? Case { get; set; }
41+
2342
/// <summary>
2443
/// Prepare an image to text task.
2544
/// </summary>
2645
/// <param name="body">Base64 encoded content of the image (without line breaks)</param>
27-
public ImageToTextTask(string body)
46+
public ImageToTextTask(string body, string? module = null, float? score = null, bool? caseSensitive = null)
2847
{
2948
Body = body;
49+
Module = module;
50+
Score = score;
51+
Case = caseSensitive;
3052
}
3153
}

0 commit comments

Comments
 (0)