(self, inputs)
| 226 | return inputs |
| 227 | |
| 228 | def handle_captcha(self, inputs): |
| 229 | m = search_pattern(self.CAPTCHA_PATTERN, self.data) |
| 230 | if m is not None: |
| 231 | captcha_url = urlparse.urljoin(self.pyfile.url, m.group(1)) |
| 232 | inputs['code'] = self.captcha.decrypt(captcha_url) |
| 233 | return |
| 234 | |
| 235 | m = search_pattern(self.CAPTCHA_BLOCK_PATTERN, self.data, re.S) |
| 236 | if m is not None: |
| 237 | captcha_div = m.group(1) |
| 238 | numerals = re.findall(r'<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div)) |
| 239 | |
| 240 | self.log_debug(captcha_div) |
| 241 | |
| 242 | inputs['code'] = "".join(a[1] for a in sorted(numerals, key=operator.itemgetter(0))) |
| 243 | |
| 244 | self.log_debug("Captcha code: %s" % inputs['code'], numerals) |
| 245 | return |
| 246 | |
| 247 | recaptcha = ReCaptcha(self.pyfile) |
| 248 | try: |
| 249 | captcha_key = search_pattern(self.RECAPTCHA_PATTERN, self.data).group(1) |
| 250 | |
| 251 | except Exception: |
| 252 | captcha_key = recaptcha.detect_key() |
| 253 | |
| 254 | else: |
| 255 | self.log_debug("ReCaptcha key: %s" % captcha_key) |
| 256 | |
| 257 | if captcha_key: |
| 258 | self.captcha = recaptcha |
| 259 | inputs['g-recaptcha-response'], _ = recaptcha.challenge(captcha_key) |
| 260 | return |
| 261 | |
| 262 | solvemedia = SolveMedia(self.pyfile) |
| 263 | try: |
| 264 | captcha_key = search_pattern(self.SOLVEMEDIA_PATTERN, self.data).group(1) |
| 265 | |
| 266 | except Exception: |
| 267 | captcha_key = solvemedia.detect_key() |
| 268 | |
| 269 | else: |
| 270 | self.log_debug("SolveMedia key: %s" % captcha_key) |
| 271 | |
| 272 | if captcha_key: |
| 273 | self.captcha = solvemedia |
| 274 | inputs['adcopy_response'], inputs['adcopy_challenge'] = solvemedia.challenge(captcha_key) |
no test coverage detected