MCPcopy Create free account
hub / github.com/VeNoMouS/cloudscraper / requestSolve

Method requestSolve

cloudscraper/captcha/anticaptcha.py:99–140  ·  view source on GitHub ↗
(self, captchaType, url, siteKey)

Source from the content-addressed store, hash-verified

97 # ------------------------------------------------------------------------------- #
98
99 def requestSolve(self, captchaType, url, siteKey):
100 def _checkRequest(response):
101 self.checkErrorStatus(response)
102
103 if response.ok and response.json()['taskId']:
104 return True
105
106 return None
107
108 data = {
109 'clientKey': self.clientKey,
110 'task': {
111 'websiteURL': url,
112 'websiteKey': siteKey,
113 'type': self.captchaType[captchaType]
114 },
115 'softId': 959
116 }
117
118 if self.proxy:
119 data['task'].update(self.proxy)
120 else:
121 data['task']['type'] = f"{data['task']['type']}Proxyless"
122
123 response = polling2.poll(
124 lambda: self.session.post(
125 f'{self.host}/createTask',
126 json=data,
127 allow_redirects=False,
128 timeout=30
129 ),
130 check_success=_checkRequest,
131 step=5,
132 timeout=180
133 )
134
135 if response:
136 return response.json()['taskId']
137 else:
138 raise CaptchaBadJobID(
139 'anticaptcha: Error no task id was returned.'
140 )
141
142 # ------------------------------------------------------------------------------- #
143

Callers 1

getCaptchaAnswerMethod · 0.95

Calls 1

CaptchaBadJobIDClass · 0.85

Tested by

no test coverage detected