def get_token(form_html): site_key = re.search(site_key_pattern, form_html).group(1) task = NoCaptchaTaskProxylessTask(website_url=url, website_key=site_key) job = client.createTask(task) job.join() return job.get_solution_response()
def get_token(self, site_key, proxy=None): # proxy = urlparse("https://"+proxy) # print(proxy.hostname) #proxy = {"proxy_type":proxy.scheme, "proxy_address":proxy.hostname, "proxy_port": proxy.port, "proxy_login": proxy.username, "proxy_password":proxy.password} client = AnticaptchaClient(API_KEY) # task = FunCaptchaTask(SITE_URL,site_key, proxy_type=proxy.scheme, proxy_address=proxy.hostname,proxy_port=proxy.port,proxy_login=proxy.username,proxy_password=proxy.password, user_agent=self.current_user_agent) task = NoCaptchaTaskProxylessTask(website_url=SITE_URL, website_key=site_key) try: #job = client.createTaskSmee(task) job = client.createTask(task) job.join(maximum_time=150) except AnticatpchaException as e: if e.error_code == 'ERROR_ZERO_BALANCE': print(e.error_id, e.error_code, e.error_description) else: if DETAILED_LOGO: self.print_logo("Exc:", e) return None except Exception as e: if DETAILED_LOGO: self.print_logo("Exc:", e) return None except timeout as e: if DETAILED_LOGO: self.print_logo("Exc", e) return None return job.get_solution_response()
def get_captcha(url, site_key): try: # if True: logging.info('Waiting for recaptcha to be solved ...') # api_key = '3d9e48e7ad1d64de378bc1dea4fd472e' api_key = 'c76f49b1ee12f7739faebf78de3534f0' headers = { 'User-Agent': ua.get_user_agent(), 'Content-Type': 'application/json', 'Accept': 'application/json' } api_call = ('{\"clientKey\":\"%s\"}') % (api_key) service_url = 'https://api.anti-captcha.com/getBalance' response = requests.post(service_url, data=api_call, headers=headers, timeout=15).text api_content = json.loads(response) logging.info( ('Anti-captcha balance: %s USD') % (str(api_content['balance']))) client = AnticaptchaClient(api_key) task = NoCaptchaTaskProxylessTask(url, site_key) job = client.createTask(task) job.join() return job.get_solution_response() except Exception as err: logging.info('Failed to resolve captcha: ' + str(err)) raise err
def get_token(url, site_key, invisible): task = NoCaptchaTaskProxylessTask(website_url=url, website_key=site_key, is_invisible=invisible) job = client.createTask(task) job.join() return job.get_solution_response()
def solve_captha(self): try: api_key = '14723f8265ec2fbffb5ac0be479e4e30' invisible_captcha = True url = 'http://tv.deluxeprime.net:25500/login.php?referrer=/users.php' client = AnticaptchaClient(api_key) task = NoCaptchaTaskProxylessTask( website_url=self.driver.current_url, website_key='6LeaXhITAAAAACiHR6YSn1YKAUrrTZTLtjxuwYx6', is_invisible=invisible_captcha) job = client.createTask(task) job.join() response = job.get_solution_response() print(self.driver.current_url) print(response) key = response command = 'document.getElementById("g-recaptcha-response").innerHTML="' + key + '";' self.driver.execute_script( "document.getElementsByName('captchaResponse')[0].setAttribute('type', 'shown');" ) self.driver.find_element_by_name("captchaResponse").send_keys(key) time.sleep(5) self.driver.execute_script(command) time.sleep(2) except Exception as e: self.driver.quit()
def insert_anticaptcha_solution(driver, group_name): try: driver.find_element_by_id("g-recaptcha-response") api_key = ANTICAPTCHA_ID site_key = SITE_KEY url = 'https://groups.google.com/forum/#!managemembers/{}/invite'.format( group_name) print('Вычисляем антикапчу') client = AnticaptchaClient(api_key) task = NoCaptchaTaskProxylessTask(url, site_key) job = client.createTask(task) job.join() response = job.get_solution_response() print("Received solution", response) time.sleep(2) driver.execute_script( 'document.getElementById("g-recaptcha-response").innerHTML = "%s"' % response) time.sleep(2) driver.execute_script( 'document.getElementById("g-recaptcha-response").innerHTML = "%s"' % response) time.sleep(2) capchaButton = driver.find_element_by_xpath('//div[@aria-disabled]') capchaButton.click() print('Все приглашения отправлены') except: error = driver.find_element_by_class_name('F0XO1GC-Nb-f').text print(error)
def solve_captcha(): driver.switch_to.frame(driver.find_elements_by_tag_name('iframe')[0]) try: check = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.XPATH, '//*[@id="recaptcha-anchor"]/div[1]'))) print("check box image captcha") except (TimeoutException, NoSuchElementException): print("no check box") client = AnticaptchaClient(API_KEY) task = NoCaptchaTaskProxylessTask(page, site_key) job = client.createTask(task) print("Waiting for solution by Anticaptcha workers") job.join() # Receive response captcha_response = job.get_solution_response() print("Received solution", captcha_response) # Inject response in webpage driver.switch_to.default_content() driver.execute_script( "arguments[0].style.display='inline'", driver.find_element_by_xpath( '//*[@id="g-recaptcha-response"]' ), ) driver.execute_script( 'document.getElementById("g-recaptcha-response").innerHTML = "%s"' % captcha_response ) driver.switch_to.default_content()
def CreateAccount(email): s = requests.session() headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36', 'Host': 'undefeated.com', 'Origin': 'https://undefeated.com', 'Referer': 'https://undefeated.com/account/register' } data = { 'form_type': 'create_customer', 'utf8': '✓', 'customer[first_name]': fname, 'customer[last_name]': lname, 'customer[email]': email, 'customer[password]': password } r1 = s.post("https://undefeated.com/account", data=data, headers=headers) if r1.url == captcha_url: print("Encountered captcha") soup = BeautifulSoup(r1.text, "html.parser") authToken = soup.find("input", {"name": "authenticity_token"})['value'] print("Sending job to anti-captcha, please wait for it to be solved") print( "If this is taking a long time to solve, go to https://anti-captcha.com/clients/reports/dashboard to check if it's still being solved" ) client = AnticaptchaClient(api_key) task = NoCaptchaTaskProxylessTask(captcha_url, sitekey) job = client.createTask(task) job.join() job.get_solution_response() headers2 = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36', 'Origin': 'https://undefeated.com', 'Referer': 'https://undefeated.com/challenge' } data2 = { 'utf8': '✓', 'authenticity_token': authToken, 'g-recaptcha-response': job.get_solution_response() } r1 = s.post("https://undefeated.com/account", data=data2, headers=headers2) if r1.url == "https://undefeated.com/": print("Successfully created an account with {}".format(email)) SaveToFile() else: print("Creation unsuccessful") else: print("Successfully created an account with {}".format(email)) SaveToFile()
def resolve(url, api_key, site_key): client = AnticaptchaClient(api_key) task = NoCaptchaTaskProxylessTask(url, site_key) job = client.createTask(task) job.join() return job.get_solution_response()
def authenticate(driver): #autentifocation window_handle = driver.window_handles[0] time.sleep(1) allow_cookies_btn = driver.find_element_by_css_selector('.cc-btn.cc-allow') if allow_cookies_btn: allow_cookies_btn.click() time.sleep(1) auth_form = driver.find_element_by_id('new_allbestbets_user') sign_in_url = auth_form.get_attribute('action') print(sign_in_url) """print(hiddens) csrf_token = soup.find('meta', {'name': 'csrf-token'}) if csrf_token: csrf_token = csrf_token.get('content') print(csrf_token)""" div_recaptcha = auth_form.find_element_by_css_selector('div.g-recaptcha') print(div_recaptcha) site_key = div_recaptcha.get_attribute('data-sitekey') print(site_key) recaptcha_url = div_recaptcha.find_element_by_xpath('preceding-sibling::script').get_attribute('src') print(recaptcha_url) time.sleep(1) submit_btn = auth_form.find_element_by_css_selector('button.button-clear') auth_form.find_element_by_id('allbestbets_user_email').send_keys(login['user']) time.sleep(1) auth_form.find_element_by_id('allbestbets_user_password').send_keys(login['pass']) time.sleep(1) solution = '' while not solution: try: client = AnticaptchaClient(anticaptcha_key) task = NoCaptchaTaskProxylessTask(recaptcha_url, site_key) job = client.createTask(task) job.join() solution = job.get_solution_response() print(solution) except Exception as exc: print(exc) time.sleep(1) driver.execute_script(f"document.getElementById('g-recaptcha-response').innerHTML='{solution}';") #recaptcha_textarea = auth_form.find_element_by_id('g-recaptcha-response') #recaptcha_textarea.send_keys(solution) recaptcha_frame = div_recaptcha.find_element_by_tag_name('iframe') driver.switch_to.frame(recaptcha_frame) driver.execute_script("document.getElementById('recaptcha-anchor').classList.remove('recaptcha-checkbox-unchecked');document.getElementById('recaptcha-anchor').classList.add('recaptcha-checkbox-checked');") #recaptcha_checkbox = driver.find_element_by_css_selector('div.recaptcha-checkbox-border') #recaptcha_checkbox.click() time.sleep(1) driver.switch_to.window(window_handle) submit_btn.click() """else:
def solveReCaptcha(self, api, sitekey = None): if sitekey == None: sitekey = self.getSiteKey() client = AnticaptchaClient(api) task = NoCaptchaTaskProxylessTask(self.driver.current_url, sitekey) job = client.createTask(task) job.join() code = job.get_solution_response() #self.inject("g-recaptcha-response", code, "id") #for me, right now this is unreliabily injecting return code
def get_recaptcha_response(cls, page): try: key = cls.get_recaptcha_key(page) client = AnticaptchaClient(cls.anticaptcha_api_key) task = NoCaptchaTaskProxylessTask(cls.auth_url, key) job = client.createTask(task) job.join() recaptcha_res = job.get_solution_response() except Exception as err: logging.error(f"Couldn't get recaptcha response / {err}") return "" return recaptcha_res
def solve_captcha_by_module(self, url: str, condition_for_finish=None): """ Решатель капчи. :param url: URl сайта с капчей :param condition_for_finish: Условие для завершения поиска капчи :return captcha response: Токен который капча дает при решении """ self.wait_page_load() self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") job = None while not job: captcha_not_found_count = 0 site_key_el = None while not site_key_el: if condition_for_finish and condition_for_finish[0](*condition_for_finish[1]): logging.info('Не надо решать капчу.') return if captcha_not_found_count == 10: raise CaptchaNotFound('Капча не найдена уже 10 раз. Рестарт.') try: site_key_el = self.driver.find_element_by_xpath('//iframe[@title="reCAPTCHA"]') except NoSuchElementException: self.switch_to_frame(par='title', arg='reCAPTCHA') logging.warning('Капча не найдена. Еще одна попытка через 5 секунд.') captcha_not_found_count += 1 site_key_el = None time.sleep(5) site_key_el_src = site_key_el.get_attribute('src') site_key = site_key_el_src[site_key_el_src.find('&k=') + 3:site_key_el_src.find('&co')] logging.info('Ожидаем решения капчи.') task = NoCaptchaTaskProxylessTask(url, site_key) job = config.anticaptcha_client.createTask(task) job.join(90) if not job: logging.warning('Не удалось решить капчу за 120 сек. Еще одна попытка.') logging.info('Капча решена.') return job.get_solution_response()
def solve_captcha(self, url, html): key_pattern = re.compile("Packt.offers.onLoadRecaptcha\(\'(.+?)\'\)") site_key = key_pattern.search(html.find(text=key_pattern)).group(1) client = AnticaptchaClient(self.account_data.anticaptcha_clientkey) task = NoCaptchaTaskProxylessTask(url, site_key) job = client.createTask(task) logger.info("Task ID {} created. Waiting to finish.".format(job.task_id)) start = time.time() job.join() end = time.time() logger.info("Taks finished in {:.2f} second".format(end - start)) return job.get_solution_response()
def get_captcha(url, api_key, site_key): print("[CHECKING] captcha (siteKey = %s, apiKey = %s)" % (site_key, api_key)) try: client = AnticaptchaClient(api_key) task = NoCaptchaTaskProxylessTask(url, site_key) job = client.createTask(task) job.join() return job.get_solution_response() except AnticaptchaException as ae: print("[ERROR] error = %s" % str(ae)) return None
def _preauth(self, action: str) -> Tuple[Session, str, str]: response = make_uri_request('GET', f'users/{action}', session := Session()) soup = BeautifulSoup(response.content, 'html.parser') recaptcha_site_key = soup.select_one('.g-recaptcha')['data-sitekey'] (solve_job := AnticaptchaClient(self.anticaptcha_token).createTask( NoCaptchaTaskProxylessTask(make_url(f'users/{action}'), recaptcha_site_key))).join() authenticity_token = soup.select_one('[name="csrf-token"]')['content'] recaptcha_token = solve_job.get_solution_response() return session, authenticity_token, recaptcha_token
def solve_captcha(url): print("solving captcha....") res = None try: client = AnticaptchaClient(API_KEY) task = NoCaptchaTaskProxylessTask(url, SITE_KEY) job = client.createTask(task) job.join() res = job.get_solution_response() print("Captcha solved !!") except Exception as err: print("Captcha not solved... Error:", err) return res
async def do_captcha(self, key: str): self.logger.info("attempting to solve captcha.") try: task = NoCaptchaTaskProxylessTask( self.tcurl.format(self.bot.settings["room"]["roomname"], key)) job = self.captcha_client.createTask(task) job.join() payload = { "tc": "captcha", "req": 1, "token": job.get_solution_response() } await self.bot.ws.send(json.dumps(payload)) except AnticatpchaException as e: self.logger.error(e) raise
def get_token(website_url, site_key, invisible): """Gets captcha solution""" task = NoCaptchaTaskProxylessTask(website_url=website_url, website_key=site_key, is_invisible=invisible) while True: try: job = client.createTask(task) job.join() response = job.get_solution_response except Exception: print(Exception) print("Captcha service failed.. Retrying") continue break return job.get_solution_response()
def getCaptchaAnswer(self, site_url, site_key, reCaptchaParams): if not reCaptchaParams.get('api_key'): raise ValueError("reCaptcha provider 'anticaptcha' was not provided an 'api_key' parameter.") client = AnticaptchaClient(reCaptchaParams.get('api_key')) if reCaptchaParams.get('proxy'): client.session.proxies = reCaptchaParams.get('proxies') task = NoCaptchaTaskProxylessTask(site_url, site_key) if not hasattr(client, 'createTaskSmee'): sys.tracebacklimit = 0 raise RuntimeError("Please upgrade 'python_anticaptcha' via pip or download it from https://github.com/ad-m/python-anticaptcha") job = client.createTaskSmee(task) return job.get_solution_response()
def getCaptchaAnswer(self, site_url, site_key, reCaptchaParams): if not reCaptchaParams.get('api_key'): raise reCaptchaParameter("anticaptcha: Missing api_key parameter.") client = AnticaptchaClient(reCaptchaParams.get('api_key')) if reCaptchaParams.get('proxy'): client.session.proxies = reCaptchaParams.get('proxies') task = NoCaptchaTaskProxylessTask(site_url, site_key) if not hasattr(client, 'createTaskSmee'): raise NotImplementedError( "Please upgrade 'python_anticaptcha' via pip or download it from " "https://github.com/ad-m/python-anticaptcha") job = client.createTaskSmee(task) return job.get_solution_response()
def solve_captcha(driver): if driver.find_elements_by_class_name('g-recaptcha'): captcha = driver.find_element_by_class_name('g-recaptcha') site_key = captcha.get_attribute('data-sitekey') log('recaptcha found') if not site_key: site_key = driver.find_element_by_css_selector( '.challenge-form script').get_attribute('data-sitekey') task = NoCaptchaTaskProxylessTask(website_url=driver.current_url, website_key=site_key) job = anticpatcha_client.createTask(task) job.join() token = job.get_solution_response() global solved_captchas solved_captchas += 1 log('recaptcha solved ({})'.format(solved_captchas)) wait( driver, EC.presence_of_element_located( (By.CSS_SELECTOR, '#g-recaptcha-response'))) driver.execute_script( 'document.getElementById("g-recaptcha-response").value="{}"'. format(token)) else: if (driver.find_elements_by_css_selector( '.verify-me-progress[role="checkbox"]') and not driver.find_elements_by_css_selector('checkmark')): wait( driver, EC.presence_of_element_located( (By.CSS_SELECTOR, '.verify-me-progress[role="checkbox"]'))).click() wait( driver, element_has_attribute((By.NAME, 'coinhive-captcha-token'), 'value'))
def solve_captcha(url, _site_key, _api_key): #Codigo dado pela anti-captcha. api_key = _api_key site_key = _site_key client = AnticaptchaClient(api_key) task = NoCaptchaTaskProxylessTask(url, site_key) job = client.createTask(task) print(cMessage + get_time() + "Aguardando resolução do captcha...") job.join() # Receive response response = job.get_solution_response() print(cMessage + get_time() + "Captcha resolvido!") # Inject response in webpage driver.execute_script( 'document.getElementById("g-recaptcha-response").innerHTML = "%s"' % response) # Wait a moment to execute the script (just in case). time.sleep(1)
def anti(): while True: api_key = ack[randint(0, len(ack) - 1)] print(api_key) site_key = settings['sitekey'] url = settings['url'] try: client = AnticaptchaClient(api_key) task = NoCaptchaTaskProxylessTask(url, site_key) job = client.createTask(task) print("solving anti captcha") job.join() capto = job.get_solution_response() capto = "[={}=]".format(capto) with open("tokens.txt", "a+") as f: f.write("{}\n".format(capto)) print("solved") except: print("error in anticaptcha thread")
def run(self): global solve while solve: client = AnticaptchaClient(self.apikey) task = NoCaptchaTaskProxylessTask(self.url, self.sitekey) try: job = client.createTask(task) except Exception: print('Anti-Captcha Balance Zero') break job.join() payload = {'g-recaptcha-response': job.get_solution_response()} while True: try: self.s.post('http://127.0.0.1:5000/solve', data=payload) break except: print( 'Please Start Captcha Harvester. (THIS STORES THE TOKENS.)' ) print('Submitted Anti-Captcha')
def getCaptchaAnswer(self, site_url, site_key, reCaptchaParams): if not reCaptchaParams.get('api_key'): raise ValueError( "reCaptcha provider 'anticaptcha' was not provided an 'api_key' parameter." ) client = AnticaptchaClient(reCaptchaParams.get('api_key')) if reCaptchaParams.get('proxy', False) and reCaptchaParams.get('proxies'): client.session.proxies = reCaptchaParams.get('proxies') task = NoCaptchaTask( site_url, site_key, proxy=Proxy.parse_url( reCaptchaParams.get('proxies').get('https'))) else: task = NoCaptchaTaskProxylessTask(site_url, site_key) job = client.createTask(task) job.join() return job.get_solution_response()
def claim_book(s): """ claim the free book :param s: session used cross script """ r = s.get(FREE_BOOk_URL, headers=headers) tree = html.fromstring(r.content) key_pattern = re.compile("Packt.offers.onLoadRecaptcha\(\'(.+?)\'\)") site_key = re.search(key_pattern, r.text).group(1) client = AnticaptchaClient(_get_configuration('anti-captcha')) task = NoCaptchaTaskProxylessTask(FREE_BOOk_URL, site_key) job = client.createTask(task) job.join() link = tree.xpath('//form[@id="free-learning-form"]/@action')[0] recaptcha = job.get_solution_response() logger.info("recaptcha-response is %s" % recaptcha) r = s.post(BASE_URL + link, data={'g-recaptcha-response': recaptcha}, headers=headers) return ('account' in r.url)
def anticaptcha_solver(): """Solves repcatcha via AntiCaptcha service""" print("Solving captcha, please wait...") client = AnticaptchaClient(API_KEY) task = NoCaptchaTaskProxylessTask(SITE_URL, SITE_KEY, is_invisible=True) while True: try: try: job = client.createTask(task) except AnticaptchaException as e: print(e) if e.error_id(2): print("No captcha solver available.. Retrying.") return True else: raise else: job.join() print('Captcha solved. Continuing.') return job.get_solution_response(), False except AnticaptchaException: sys.exit(AnticaptchaException)
def solve_captcha(driver): try: log('solving recaptcha') site_key = re.search(r"sitekey: '(.*?)'", driver.page_source).group(1) task = NoCaptchaTaskProxylessTask(website_url=driver.current_url, website_key=site_key) job = anticpatcha_client.createTask(task) job.join() token = job.get_solution_response() try: driver.execute_script(config.ROLL_SCRIPT, token) except: pass try: driver.execute_script('sendLogin(arguments[0])', token) except: pass try: driver.execute_script('sendRegister(arguments[0])', token) except: pass global solved_captchas solved_captchas += 1 log('recaptcha solved ({})'.format(solved_captchas)) return True except Exception as e: check_for_alert(driver) log(e, type='error')
def enter_raffle(email): log('i', "Signing up with email <" + email + ">.") sess = requests.Session() ua = UserAgent() currentDT = datetime.datetime.now() timing = currentDT.strftime("%Y-%m-%d"+"T"+"%H:%M:%S"+"-04:00") link = "https://slamjamsocialism-drops.com/graphql" anti_api_key = "" #ENTER YOUR ANTI-CAPTCHA KEY HERE site_key = "6LfYhz0UAAAAAJFKp28Sg0NnAEIPMfKI1RJSGsdB" client = AnticaptchaClient(anti_api_key) task = NoCaptchaTaskProxylessTask(link, site_key) job = client.createTask(task) job.join() captcha = job.get_solution_response() headers = { "authority": "slamjamsocialism-drops.com", "method": "POST", "path": "/graphql", "scheme": "https", "accept": "*/*", "accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en;q=0.9", "authorization": "null", "content-type": "application/json", "dnt": "1", "origin": "https://slamjamsocialism-drops.com", "referer": "https://slamjamsocialism-drops.com/drops/140", "user-agent": str(ua.Chrome) } r = sess.get("https://slamjamsocialism-drops.com/drops/140", headers=headers) #print(r.headers) #print(r.request.headers) #print(r.cookies) data = { "query":"mutation RequestOrdertMutation($data: OrderRequestInput!) {\n requestOrder(data: $data)\n}\n", "operationName":"RequestOrdertMutation", "variables":{ "data":{ "firstName":first_name, "lastName":last_name, "email":email, "phone":phone, "country":"840", "city":city, "order":[ { "product":"115", "size":size } ], "raffle":"140", "captcha": captcha, "date":str(timing) } } } proxy_list =[ "US-10m.geosurf.io:10001", "US-10m.geosurf.io:10002", "US-10m.geosurf.io:10003", "US-10m.geosurf.io:10004", "US-10m.geosurf.io:10005", "US-10m.geosurf.io:10006", "US-10m.geosurf.io:10007", "US-10m.geosurf.io:10008", #enter like this separate with commas ] random_proxy = random.choice(proxy_list) proxy= { "http": random_proxy } response = sess.post("https://slamjamsocialism-drops.com/graphql", headers=headers, json=data, proxies=proxy) #print(response.status_code) #print(response.content) content_type_header = response.headers.get('content-type') flag = b'\x83\x0e\x00\x00\x04\x9aq\xe4/\x98H"\x1bH\xda\xd5\x92LR\xca,\xea:-\x95%T\xc0\x9d\xfb\xa0t\xc16' in response.content return flag