def checkCaptcha(self, input): if "Our systems have detected unusual traffic from your computer network" in input.text: SITE_KEY = "6LfwuyUTAAAAAOAmoS0fdqijC2PbbdH4kjq62Y1b" PAGE_URL = "https://ipv4.google.com/sorry/index" print('got captcha, requesting anticaptcha') user_answer = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key=self.ANTICAPTCHA_KEY) \ .captcha_handler(websiteURL=PAGE_URL, websiteKey=SITE_KEY) inbs = bs(input.text) acq = inbs.find("input", { "type": "hidden", "name": "q" }).attrs['value'] acc = inbs.find("input", { "type": "hidden", "name": "continue" }).attrs['value'] sr = requests.post("https://ipv4.google.com/sorry/index", { "g-recaptcha-response": user_answer['solution']['gRecaptchaResponse'], "q": acq, "continue": acc, "submit": "Submit" }, headers=self.headers) return self.checkCaptcha(sr) return input
def solveCaptcha(PAGE_URL): ANTICAPTCHA_KEY = "cfff02538f8b393ab3df35257154f982" SITE_KEY = '6LeuMjIUAAAAAODtAglF13UiJys0y05EjZugej6b' user_answer = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless( anticaptcha_key=ANTICAPTCHA_KEY).captcha_handler(websiteURL=PAGE_URL, websiteKey=SITE_KEY) return user_answer
def _solve_antigate_captcha(self, captcha_key): self._log('Resolving captcha in Antigate') task = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key=self.antigate_key) result = task.captcha_handler(websiteURL='https://vk.com', websiteKey=captcha_key) if result['errorId'] == 0 and 'solution' in result: solution = result['solution'] if 'gRecaptchaResponse' in solution: return solution['gRecaptchaResponse'] return False
def anti_captcha(sitekey, pageurl): from python3_anticaptcha import NoCaptchaTaskProxyless user_answer = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key = anticaptcha_key)\ .captcha_handler(websiteURL=pageurl, websiteKey=sitekey) if user_answer['errorId'] == 0: return user_answer['solution']['gRecaptchaResponse'] else: print("retry get response") anti_captcha(sitekey, pageurl)
def process_reptcha_request(self): # self.user_answer = NoCaptchaTaskProxyless(anticaptcha_key = self.ANTICAPTCHA_KEY).captcha_handler(websiteURL=self.PAGE_URL, websiteKey=self.SITE_KEY) # self repeat = False while not repeat: try: self.user_answer = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key = self.ANTICAPTCHA_KEY).captcha_handler(websiteURL=self.PAGE_URL, websiteKey=self.SITE_KEY) repeat = True except: print("Error connecting re-captcha service.. Retrying") time.sleep(1) repeat = False return self.user_answer
def test_aionocaptcha_proxyless_context(self): with NoCaptchaTaskProxyless.aioNoCaptchaTaskProxyless( anticaptcha_key=self.anticaptcha_key) as nocaptcha: # check response type assert type( nocaptcha ) is python3_anticaptcha.NoCaptchaTaskProxyless.NoCaptchaTaskProxyless response = yield nocaptcha.captcha_handler( websiteURL='https://www.google.com/recaptcha/api2/demo', websiteKey='6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-') # check response type assert type(response) is dict # check all dict keys assert ['errorId', 'errorCode', 'errorDescription'] == list(response.keys())
def test_fail_aionocaptcha_proxyless(self): nocaptcha = NoCaptchaTaskProxyless.aioNoCaptchaTaskProxyless( anticaptcha_key=self.anticaptcha_key_fail) # check response type assert type(nocaptcha) is NoCaptchaTaskProxyless.NoCaptchaTaskProxyless response = yield nocaptcha.captcha_handler( websiteURL="https://www.google.com/recaptcha/api2/demo", websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", ) # check response type assert type(response) is dict # check all dict keys assert ["errorId", "errorCode", "errorDescription"] == list(response.keys()) # check error code assert response["errorId"] == 1
def test_nocaptcha_proxyless_context(self): with NoCaptchaTaskProxyless.NoCaptchaTaskProxyless( anticaptcha_key=self.anticaptcha_key) as nocaptcha: # check response type assert (type(nocaptcha) is python3_anticaptcha. NoCaptchaTaskProxyless.NoCaptchaTaskProxyless) response = nocaptcha.captcha_handler( websiteURL="https://www.google.com/recaptcha/api2/demo", websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", ) # check response type assert type(response) is dict # check all dict keys assert ["errorId", "errorCode", "errorDescription"] == list(response.keys())
import asyncio import requests from python3_anticaptcha import NoCaptchaTaskProxyless, NoCaptchaTask, CallbackClient ANTICAPTCHA_KEY = "ae23fffcfaa29b170e3843e3a486ef19" # Пример показывает работу антикапчи с "невидимой" рекапчёй от гугла, точно так же работает обычная рекапча от гугла. # Это метод для работы без прокси result = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key = ANTICAPTCHA_KEY)\ .captcha_handler(websiteURL='https://www.google.com/recaptcha/api2/demo', websiteKey='6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-') print(result) # Пример работы антикапчи с гугловской невидимой рекапчёй и обычной рекапчёй с использованием ПРОКСИ result = NoCaptchaTask.NoCaptchaTask(anticaptcha_key = ANTICAPTCHA_KEY, proxyType='http', proxyAddress="8.8.8.8", proxyPort=8080, proxyLogin="******", proxyPassword="******")\ .captcha_handler(websiteURL='https://www.google.com/recaptcha/api2/demo', websiteKey='6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-') print(result) # Асинхронный пример async def run(): try: result = await NoCaptchaTaskProxyless.aioNoCaptchaTaskProxyless(anticaptcha_key=ANTICAPTCHA_KEY) \
2. vhost - название виртуального хоста(в данном случаи - `anticaptcha_vhost`) """ answer = requests.post( "http://85.255.8.26:8001/register_key", json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"}, ) # если очередь успешно создана: if answer == "OK": # Пример показывает работу антикапчи с "невидимой" рекапчёй от гугла, точно так же работает обычная рекапча от гугла. # Это метод для работы без прокси result = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless( anticaptcha_key=ANTICAPTCHA_KEY, callbackUrl=f"http://85.255.8.26:8001/anticaptcha/nocaptcha/{QUEUE_KEY}", ).captcha_handler( websiteURL="https://www.google.com/recaptcha/api2/demo", websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", ) print(result) # получение результата из кеша print(CallbackClient.CallbackClient(task_id=result["taskId"]).captcha_handler()) # получение результата из RabbitMQ очереди с переопределением стандартных параметров print( CallbackClient.CallbackClient( task_id=result["taskId"], queue_name=QUEUE_KEY, call_type="queue" ).captcha_handler( requests_timeout=0.5, auth_params={ "host": "85.255.8.26",
import asyncio import requests from python3_anticaptcha import NoCaptchaTaskProxyless, NoCaptchaTask, CallbackClient ANTICAPTCHA_KEY = "ae23fffcfaa29b170e3843e3a486ef19" """ Синхронный пример без прокси Sync example without proxy """ result = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless( anticaptcha_key=ANTICAPTCHA_KEY).captcha_handler( websiteURL="https://www.google.com/recaptcha/api2/demo", websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", ) print(result) """ Синхронный пример с контекстным менеджером и без прокси Sync example with contextmanager and without proxy """ with NoCaptchaTaskProxyless.NoCaptchaTaskProxyless( anticaptcha_key=ANTICAPTCHA_KEY) as nocaptcha: response = nocaptcha.captcha_handler( websiteURL="https://www.google.com/recaptcha/api2/demo", websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", ) print(response) """ Синхронный пример с прокси Sync example with proxy """
actions = ActionChains(driver) actions.move_to_element(message_click[j]).perform() #location = message_click[j].location["y"] - 100 #driver.execute_script("window.scrollTo(0, %d);" % location) #message_click[j].click() try: message_click[j].click() except WebDriverException: location = message_click[j].location["y"] - 100 driver.execute_script("window.scrollTo(0, %d);" % location) time.sleep(3) try: message_click[j].click() except WebDriverException: result = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key=api_key) \ .captcha_handler(websiteURL=url, websiteKey=site_key) #result = ReCaptchaV2.ReCaptchaV2(rucaptcha_key=api_key).captcha_handler(site_key=site_key, # page_url=url) #gcap1 = requests.post(url, result) print(result) response_dict = result.get('solution') response = response_dict.get('gRecaptchaResponse') #response = result['captchaSolve'] print(response) try: driver.execute_script( "document.getElementById('g-recaptcha-response').style.removeProperty('display');" ) driver.find_element_by_id(
def captcha_solve(browser, cost_file='costs.txt', ANTICAPTCHA_KEY=None, save_cost=True, captcha_sound=True, domain=None): if not ANTICAPTCHA_KEY: ANTICAPTCHA_KEY = os.getenv('ANTICAPTCHA_KEY') if not domain: domain = browser.current_url xpath = '//*[@id = "g-recaptcha-response"]' try: browser.find_element_by_xpath(xpath) # Captcha found in page exist_captcha = True except: # Captcha CAN NOT found in page exist_captcha = False user_answer = None cost = 0 start_time = time.time() if exist_captcha: if captcha_sound: Progress.sound_notify_times(times=1) print('--> reCAPTCHA solving. It might take some time, please wait...') key = '' try: SITE_KEY = None try: # TRY normal captcha box xpath = '//*[contains(@class,"g-recaptcha")]' captcha_box = browser.find_element_by_xpath(xpath) SITE_KEY = captcha_box.get_attribute('data-sitekey') if not SITE_KEY: raise Exception except: # Normal captcha box COULD NOT BE FOUND. Find site key from new generation of reCAPTCHA xpath = '//iframe[contains(@role, "presentation")]' captcha_box = browser.find_element_by_xpath(xpath) captcha_src = captcha_box.get_attribute('src') if 'k=' in captcha_src and '&' in captcha_src: captcha_src_list = captcha_src.split('&') for i in captcha_src_list: if i.startswith('k='): SITE_KEY = i.replace('k=', '') break if not SITE_KEY: raise Exception user_answer = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless( anticaptcha_key=ANTICAPTCHA_KEY).captcha_handler( websiteURL=domain, websiteKey=SITE_KEY) if 'errorDescription' in user_answer: raise Exception key = user_answer['solution']['gRecaptchaResponse'] try: cost = user_answer['cost'] cost = float(cost) except: cost = 0 # Code worked untill here so there is no error. error_captcha = False except Exception as e: error_captcha = True message = '--> An error occurred while solving reCAPTCHA. Processing is in progress.' if 'errorDescription' in user_answer: message_from_system = user_answer['errorDescription'] message = message + '\n' + str(message_from_system) Progress.exit_app(e=e, message=message, exit_all=False) if not error_captcha: if 'endTime' in user_answer and 'createTime' in user_answer: end_time = user_answer['endTime'] create_time = user_answer['createTime'] pass_time = end_time - create_time else: pass_time = time.time() - start_time print('\nCalculation time: %s' % Progress.time_definition(pass_time)) print('reCAPTCHA solved. Price: $%s' % cost) if save_cost: if cost != 0 and isinstance(cost, (int, float)): read_record = File.read_records_to_list(txt_file=cost_file, file_not_found_error=False, exit_all=False) try: balance = float(read_record[0]) except: balance = 0 balance += cost File.save_records_list(txt_file=cost_file, records_list=[balance], overwrite=True, exit_all=False) # ADD SOLUTION TO THE PAGE. try: browser.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "%s"' % key) except: pass return exist_captcha
import asyncio from python3_anticaptcha import NoCaptchaTaskProxyless, NoCaptchaTask ANTICAPTCHA_KEY = "" # Пример показывает работу антикапчи с "невидимой" рекапчёй от гугла, точно так же работает обычная рекапча от гугла. # Это метод для работы без прокси result = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key = ANTICAPTCHA_KEY)\ .captcha_handler(websiteURL='https://www.google.com/recaptcha/intro/android.html', websiteKey='6LeuMjIUAAAAAODtAglF13UiJys0y05EjZugej6b') print(result) # Пример работы антикапчи с гугловской невидимой рекапчёй и обычной рекапчёй с использованием ПРОКСИ result = NoCaptchaTask.NoCaptchaTask(anticaptcha_key = ANTICAPTCHA_KEY, proxyType='http', proxyAddress="8.8.8.8", proxyPort=8080, proxyLogin="******", proxyPassword="******")\ .captcha_handler(websiteURL='https://www.google.com/recaptcha/intro/android.html', websiteKey='6LeuMjIUAAAAAODtAglF13UiJys0y05EjZugej6b') print(result) # Асинхронный пример async def run(): try: result = await NoCaptchaTaskProxyless.aioNoCaptchaTaskProxyless(anticaptcha_key=ANTICAPTCHA_KEY) \ .captcha_handler(websiteURL='https://www.google.com/recaptcha/intro/android.html',