def get_captcha(self, max_attempts=5, attempt_count=0): while attempt_count <= max_attempts: print "Attempt # " + str(attempt_count) req = RequestPage(self.id_num) captcha_id = req.request_captcha_page() print "captcha ID = " + str(captcha_id) if captcha_id is None: self.get_captcha(max_attempts, attempt_count) req.download_captcha(captcha_id) captcha_string = SolveCaptcha.solve_captcha(self.IMG_PATH + captcha_id + '.jpg') self._delete_captcha_img(captcha_id) attempt_count += 1 if captcha_string is not None and len(captcha_string) == 5: #print captcha_string #req.get_verfy(captcha_string) return {'captcha': captcha_string, 'view_state': req.view_state, 'event_validation': req.event_validation} else: self.get_captcha(max_attempts, attempt_count)
def request_verify(self, payload): ''' Send http POST request to verify driver license number :param payload: :return: ''' verify_html = RequestPage.get_verfy(self.id_num, payload['captcha'], payload['view_state'], payload['event_validation']) return self._check_for_verify(verify_html)