-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcheck.py
More file actions
129 lines (92 loc) · 3.41 KB
/
check.py
File metadata and controls
129 lines (92 loc) · 3.41 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from capsolver.error import CapsolverError
SUPPORT_TASK_TYPE = [
"HCaptchaTask",
"HCaptchaTaskProxyLess",
"HCaptchaEnterpriseTask",
"HCaptchaEnterpriseTaskProxyLess",
"FunCaptchaTask",
"FunCaptchaTaskProxyLess",
"GeeTestTask",
"GeeTestTaskProxyLess",
"ReCaptchaV2Task",
"ReCaptchaV2TaskProxyLess",
"ReCaptchaV2EnterpriseTaskProxyLess",
"ReCaptchaV2EnterpriseTask",
"ReCaptchaV3Task",
"ReCaptchaV3TaskProxyLess",
"MtCaptchaTask",
"MtCaptchaTaskProxyLess",
"DataDomeSliderTask",
"AntiCloudflareTask",
"AntiKasadaTask",
"AntiAkamaiBMPTask",
"ImageToTextTask",
"HCaptchaClassification",
"FunCaptchaClassification",
"AwsWafClassification",
]
def captcha_basic_check(params:dict):
params_keys = params.keys()
if "websiteURL" not in params_keys:
return CapsolverError("need websiteURL param")
if "websiteKey" not in params_keys:
return CapsolverError("need websiteKey param")
return None
def check_recaptcha(params:dict):
return captcha_basic_check(params)
def check_hcaptcha(params):
r = captcha_basic_check(params)
if not r:
return r
return None
def check_funcaptcha(params:dict):
params_keys = params.keys()
if "websiteURL" not in params_keys:
return CapsolverError("need websiteURL param")
if "websitePublicKey" not in params_keys:
return CapsolverError("need websitePublicKey param")
return None
def check_mtcaptcha(params:dict):
r = captcha_basic_check(params)
if not r:
return r
return None
def _format_all_task_type():
list_types = []
for i in range(len(SUPPORT_TASK_TYPE)):
list_types.append(f"{i}. {SUPPORT_TASK_TYPE[i]}")
return "\n".join(list_types)
def _check_params(params:dict):
captcha_type:str = params["type"]
if params["type"] not in SUPPORT_TASK_TYPE:
return CapsolverError("unsupport TaskType" +captcha_type+"\n support types as follow \n"+_format_all_task_type())
captcha_type = captcha_type.lower()
if "recaptcha" in captcha_type:
return check_recaptcha(params)
if "hcaptcha" in captcha_type:
return check_hcaptcha(params)
if "funcaptcha" in captcha_type:
return check_funcaptcha(params)
if "mtcaptcha" in captcha_type:
return captcha_basic_check()
if "geetesttask" in captcha_type:
if "gt" not in params.keys():
return CapsolverError(captcha_type+" need gt param")
if "challenge" not in params.keys():
return CapsolverError(captcha_type+" need challenge param")
if "datadom" in captcha_type:
if "proxy" not in params.keys():
return CapsolverError(captcha_type+" need proxy param")
if "userAgent" not in params.keys():
return CapsolverError(captcha_type+" need userAgent")
if "anticloudflare" in captcha_type:
if "metadata" not in params.keys():
return CapsolverError(captcha_type+" need metadata param")
if "antikasada" in captcha_type:
if "pageURL" not in params.keys():
return CapsolverError(captcha_type+" need pageURL param")
if "proxy" not in params.keys():
return CapsolverError(captcha_type+" need proxy param")
if "antiakamaibmp" in captcha_type:
if "packageName" not in params.keys():
return CapsolverError(captcha_type+" need packageName param")