11import base64
22
33
4- class BaseTask ( object ) :
4+ class BaseTask :
55 type = None
66
77 def serialize (self , ** result ):
@@ -12,21 +12,21 @@ def serialize(self, **result):
1212class UserAgentMixin (BaseTask ):
1313 def __init__ (self , * args , ** kwargs ):
1414 self .userAgent = kwargs .pop ("user_agent" )
15- super (UserAgentMixin , self ).__init__ (* args , ** kwargs )
15+ super ().__init__ (* args , ** kwargs )
1616
1717 def serialize (self , ** result ):
18- data = super (UserAgentMixin , self ).serialize (** result )
18+ data = super ().serialize (** result )
1919 data ["userAgent" ] = self .userAgent
2020 return data
2121
2222
2323class CookieMixin (BaseTask ):
2424 def __init__ (self , * args , ** kwargs ):
2525 self .cookies = kwargs .pop ("cookies" , "" )
26- super (CookieMixin , self ).__init__ (* args , ** kwargs )
26+ super ().__init__ (* args , ** kwargs )
2727
2828 def serialize (self , ** result ):
29- data = super (CookieMixin , self ).serialize (** result )
29+ data = super ().serialize (** result )
3030 if self .cookies :
3131 data ["cookies" ] = self .cookies
3232 return data
@@ -39,10 +39,10 @@ def __init__(self, *args, **kwargs):
3939 self .proxyPort = kwargs .pop ("proxy_port" )
4040 self .proxyLogin = kwargs .pop ("proxy_login" )
4141 self .proxyPassword = kwargs .pop ("proxy_password" )
42- super (ProxyMixin , self ).__init__ (* args , ** kwargs )
42+ super ().__init__ (* args , ** kwargs )
4343
4444 def serialize (self , ** result ):
45- data = super (ProxyMixin , self ).serialize (** result )
45+ data = super ().serialize (** result )
4646 data ["proxyType" ] = self .proxyType
4747 data ["proxyAddress" ] = self .proxyAddress
4848 data ["proxyPort" ] = self .proxyPort
@@ -74,10 +74,10 @@ def __init__(
7474 self .websiteSToken = website_s_token
7575 self .recaptchaDataSValue = recaptcha_data_s_value
7676 self .isInvisible = is_invisible
77- super (NoCaptchaTaskProxylessTask , self ).__init__ (* args , ** kwargs )
77+ super ().__init__ (* args , ** kwargs )
7878
7979 def serialize (self , ** result ):
80- data = super (NoCaptchaTaskProxylessTask , self ).serialize (** result )
80+ data = super ().serialize (** result )
8181 data ["websiteURL" ] = self .websiteURL
8282 data ["websiteKey" ] = self .websiteKey
8383 if self .websiteSToken is not None :
@@ -117,10 +117,10 @@ def __init__(
117117 self .websiteKey = website_key
118118 self .funcaptchaApiJSSubdomain = subdomain
119119 self .data = data
120- super (FunCaptchaProxylessTask , self ).__init__ (* args , ** kwargs )
120+ super ().__init__ (* args , ** kwargs )
121121
122122 def serialize (self , ** result ):
123- data = super (FunCaptchaProxylessTask , self ).serialize (** result )
123+ data = super ().serialize (** result )
124124 data ["websiteURL" ] = self .websiteURL
125125 data ["websitePublicKey" ] = self .websiteKey
126126 if self .funcaptchaApiJSSubdomain :
@@ -157,7 +157,8 @@ def __init__(
157157 max_length = None ,
158158 comment = None ,
159159 website_url = None ,
160- * args , ** kwargs
160+ * args ,
161+ ** kwargs
161162 ):
162163 self .fp = fp
163164 self .phrase = phrase
@@ -168,19 +169,27 @@ def __init__(
168169 self .maxLength = max_length
169170 self .comment = comment
170171 self .websiteUrl = website_url
171- super (ImageToTextTask , self ).__init__ (* args , ** kwargs )
172+ super ().__init__ (* args , ** kwargs )
172173
173174 def serialize (self , ** result ):
174- data = super (ImageToTextTask , self ).serialize (** result )
175+ data = super ().serialize (** result )
175176 data ["body" ] = base64 .b64encode (self .fp .read ()).decode ("utf-8" )
176- data ["phrase" ] = self .phrase
177- data ["case" ] = self .case
178- data ["numeric" ] = self .numeric
179- data ["math" ] = self .math
180- data ["minLength" ] = self .minLength
181- data ["maxLength" ] = self .maxLength
182- data ["comment" ] = self .comment
183- data ["websiteUrl" ] = self .websiteUrl
177+ if self .phrase is not None :
178+ data ["phrase" ] = self .phrase
179+ if self .case is not None :
180+ data ["case" ] = self .case
181+ if self .numeric is not None :
182+ data ["numeric" ] = self .numeric
183+ if self .math is not None :
184+ data ["math" ] = self .math
185+ if self .minLength is not None :
186+ data ["minLength" ] = self .minLength
187+ if self .maxLength is not None :
188+ data ["maxLength" ] = self .maxLength
189+ if self .comment is not None :
190+ data ["comment" ] = self .comment
191+ if self .websiteUrl is not None :
192+ data ["websiteUrl" ] = self .websiteUrl
184193 return data
185194
186195
@@ -200,10 +209,10 @@ def __init__(
200209 self .minScore = min_score
201210 self .pageAction = page_action
202211 self .isEnterprise = is_enterprise
203- super (RecaptchaV3TaskProxyless , self ).__init__ (* args , ** kwargs )
212+ super ().__init__ (* args , ** kwargs )
204213
205214 def serialize (self , ** result ):
206- data = super (RecaptchaV3TaskProxyless , self ).serialize (** result )
215+ data = super ().serialize (** result )
207216 data ["websiteURL" ] = self .websiteURL
208217 data ["websiteKey" ] = self .websiteKey
209218 data ["minScore" ] = self .minScore
@@ -220,10 +229,10 @@ class HCaptchaTaskProxyless(BaseTask):
220229 def __init__ (self , website_url , website_key , * args , ** kwargs ):
221230 self .websiteURL = website_url
222231 self .websiteKey = website_key
223- super (HCaptchaTaskProxyless , self ).__init__ (* args , ** kwargs )
232+ super ().__init__ (* args , ** kwargs )
224233
225234 def serialize (self , ** result ):
226- data = super (HCaptchaTaskProxyless , self ).serialize (** result )
235+ data = super ().serialize (** result )
227236 data ["websiteURL" ] = self .websiteURL
228237 data ["websiteKey" ] = self .websiteKey
229238 return data
@@ -245,10 +254,10 @@ def __init__(self, website_url, website_key, enterprise_payload, api_domain, *ar
245254 self .websiteKey = website_key
246255 self .enterprisePayload = enterprise_payload
247256 self .apiDomain = api_domain
248- super (RecaptchaV2EnterpriseTaskProxyless , self ).__init__ (* args , ** kwargs )
257+ super ().__init__ (* args , ** kwargs )
249258
250259 def serialize (self , ** result ):
251- data = super (RecaptchaV2EnterpriseTaskProxyless , self ).serialize (** result )
260+ data = super ().serialize (** result )
252261 data ["websiteURL" ] = self .websiteURL
253262 data ["websiteKey" ] = self .websiteKey
254263 if self .enterprisePayload :
@@ -258,7 +267,9 @@ def serialize(self, **result):
258267 return data
259268
260269
261- class RecaptchaV2EnterpriseTask (ProxyMixin , UserAgentMixin , CookieMixin , BaseTask ):
270+ class RecaptchaV2EnterpriseTask (
271+ ProxyMixin , UserAgentMixin , CookieMixin , RecaptchaV2EnterpriseTaskProxyless
272+ ):
262273 type = "RecaptchaV2EnterpriseTask"
263274
264275
@@ -278,10 +289,10 @@ def __init__(
278289 self .challenge = challenge
279290 self .geetestApiServerSubdomain = subdomain
280291 self .geetestGetLib = lib
281- super (GeeTestTaskProxyless , self ).__init__ (* args , ** kwargs )
292+ super ().__init__ (* args , ** kwargs )
282293
283294 def serialize (self , ** result ):
284- data = super (GeeTestTaskProxyless , self ).serialize (** result )
295+ data = super ().serialize (** result )
285296 data ["websiteURL" ] = self .websiteURL
286297 data ["gt" ] = self .gt
287298 data ["challenge" ] = self .challenge
@@ -306,10 +317,10 @@ def __init__(self, website_url, template_name, variables, *args, **kwargs):
306317 self .websiteURL = website_url
307318 self .templateName = template_name
308319 self .variables = variables
309- super (AntiGateTaskProxyless ).__init__ (self , * args , ** kwargs )
320+ super ().__init__ (* args , ** kwargs )
310321
311322 def serialize (self , ** result ):
312- data = super (AntiGateTaskProxyless , self ).serialize (** result )
323+ data = super ().serialize (** result )
313324 data ["websiteURL" ] = self .websiteURL
314325 data ["templateName" ] = self .templateName
315326 data ["variables" ] = self .variables
0 commit comments