Merge pull request #4 from redV0ID/master

Правочки
This commit is contained in:
Andrei 2017-10-27 23:01:41 +03:00 committed by GitHub
commit 0636f2d6e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 12 deletions

View File

@ -4,11 +4,8 @@ from .config import create_task_url, get_result_url, app_key, user_agent_data
class NoCaptchaTask: class NoCaptchaTask:
"""
TODO def __init__(self, anticaptcha_key, website_url, website_key, proxy_type="http", proxy_adress=None,
"""
# Добавить прокси адрес
def __init__(self, anticaptcha_key, website_url, website_key, proxy_type="http", proxy_adress="?",
proxy_prot=None, proxy_password=None sleep_time=5, user_agent=user_agent_data, **kwargs): proxy_prot=None, proxy_password=None sleep_time=5, user_agent=user_agent_data, **kwargs):
""" """
TODO TODO
@ -20,17 +17,19 @@ class NoCaptchaTask:
self.website_url = website_url self.website_url = website_url
self.website_key = website_key self.website_key = website_key
self.proxy_type = proxy_type self.proxy_type = proxy_type
self.proxy_adress = proxy_adress
self.proxy_login = proxy_login
self.proxy_password = proxy_password
#TODO заполнить пайлоад для решения рекапчи #TODO заполнить пайлоад для решения рекапчи
self.task_payload = {"clientKey": self.ANTIKAPTCHA_KEY, self.task_payload = {"clientKey": self.ANTIKAPTCHA_KEY,
"task": "task":
{ {
"type": "NoCaptchaTask", "type": "NoCaptchaTask",
"website_url": self.website_url,
"website_key": self.website_key,
"proxy_type": self.proxy_type, "proxy_type": self.proxy_type,
"proxy_adress": None, "proxy_adress": self.proxy_adress,
"proxy_login": None, "proxy_login": self.proxy_login,
"proxy_password": None "proxy_password": self.proxy_password
} }
} }
@ -39,7 +38,9 @@ class NoCaptchaTask:
self.task_payload['task'].update({key: kwargs[key]}) self.task_payload['task'].update({key: kwargs[key]})
def captcha_handler(self): def captcha_handler(self, websiteURL, websiteKey):
self.task_payload['task'].update({"websiteURL": websiteURL,
"websiteKey": websiteKey})
# отправляем реквест # отправляем реквест
captcha_id = requests.post(create_task_url, json=self.task_payload).json() captcha_id = requests.post(create_task_url, json=self.task_payload).json()
@ -49,6 +50,15 @@ class NoCaptchaTask:
else: else:
return captcha_id return captcha_id
# Ждем решения капчи
time.sleep(self.sleep_time) time.sleep(self.sleep_time)
while True: while True:
pass captcha_response = requests.post(get_result_url, json=self.result_payload)
if captcha_response.json()["errorId"] == 0:
if captcha_response.json()["status"] == "processing":
time.sleep(self.sleep_time)
else:
return captcha_response.json()
else:
return captcha_response.json()