def register(first_name, last_name, email, password): session = requests.Session() html = session.get(REGISTER_URL) form = parse_form(html.content) form['first_name'] = first_name form['last_name'] = last_name form['email'] = email form['password'] = form['password_two'] = password api_key = get_api_key() img = get_captcha_img(html.content) api = CaptchaAPI(api_key) captcha_id, captcha = api.solve(img) form['recaptcha_response_field'] = captcha resp = session.post(html.url, form) success = '/user/register' not in resp.url if success: api.report(captcha_id, 1) else: form_errors = fromstring(resp.content).cssselect('div.error') print('Form Errors:') print('\n'.join( (' {}: {}'.format(f.get('id'), f.text) for f in form_errors))) if 'invalid' in [f.text for f in form_errors]: api.report(captcha_id, 0) return success
def register(first_name, last_name, email, password): session = requests.Session() html = session.get(REGISTER_URL) form = parse_form(html.content) form['first_name'] = first_name form['last_name'] = last_name form['email'] = email form['password'] = form['password_two'] = password img_data = get_b64_string(html.content) img = get_captcha_img(html.content) img.show() # This will show the image locally when run api_key = get_api_key() captcha_id = send_captcha(api_key, img_data) print('submitted captcha, got id:', captcha_id) sleep(300) captcha = get_captcha_text(api_key, captcha_id) print('captcha solve:', captcha) form['recaptcha_response_field'] = captcha resp = session.post(html.url, form) success = '/user/register' not in resp.url if not success: form_errors = fromstring(resp.content).cssselect('div.error') print('Form Errors:') print('\n'.join( (' {}: {}'.format(f.get('id'), f.text) for f in form_errors))) return success
def register(first_name, last_name, email, password): session = requests.Session() html = session.get(REGISTER_URL) form = parse_form(html.content) form['first_name'] = first_name form['last_name'] = last_name form['email'] = email form['password'] = form['password_two'] = password img = get_captcha_img(html.content) captcha = ocr(img) form['recaptcha_response_field'] = captcha resp = session.post(html.url, form) success = '/user/register' not in resp.url if not success: form_errors = fromstring(resp.content).cssselect('div.error') print('Form Errors:') print('\n'.join( (' {}: {}'.format(f.get('id'), f.text) for f in form_errors))) return success