From bddb5b2ecd0eff99257d8a00f976c43ebfa4b9a0 Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 30 Mar 2020 03:45:59 +0300 Subject: [PATCH] Refactor examples --- .../anticaptcah_image_to_text_example.py | 19 ++++++++++++------- .../anticaptcha_fun_example.py | 7 ++++--- .../anticaptcha_nocaptcha_example.py | 5 +++-- .../anticaptcha_square_net_task.py | 5 +++-- anticaptcha_examples/callback_examples.py | 11 ++++++----- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/anticaptcha_examples/anticaptcah_image_to_text_example.py b/anticaptcha_examples/anticaptcah_image_to_text_example.py index 655e7ec..aa2e52a 100644 --- a/anticaptcha_examples/anticaptcah_image_to_text_example.py +++ b/anticaptcha_examples/anticaptcah_image_to_text_example.py @@ -25,14 +25,16 @@ result = ImageToTextTask.ImageToTextTask( anticaptcha_key=ANTICAPTCHA_KEY, save_format="const" -).captcha_handler(captcha_link="http://85.255.8.26/static/image/common_image_example/800070.png") +).captcha_handler( + captcha_link="https://pythoncaptcha.cloud/static/image/common_image_example/800070.png" +) print(result) # Пример который показывает работу антикапчи при решении капчи-изображением и сохранением её в качестве ВРЕМЕННОГО файла # Протестировано на Линуксах. Не используйте данный вариант на Windows! Возможно починим, но потом. # Example for working with captcha-image like a temporary file. Tested on UNIX-based systems. Don`t use it on Windows! result = ImageToTextTask.ImageToTextTask(anticaptcha_key=ANTICAPTCHA_KEY).captcha_handler( - captcha_link="http://85.255.8.26/static/image/common_image_example/800070.png" + captcha_link="https://pythoncaptcha.cloud/static/image/common_image_example/800070.png" ) print(result) @@ -43,7 +45,9 @@ An example of working with decoding in base64 captcha-file after download. On-the-fly-encoding """ base_64_link = base64.b64encode( - requests.get("http://85.255.8.26/static/image/common_image_example/862963.png").content + requests.get( + "https://pythoncaptcha.cloud/static/image/common_image_example/862963.png" + ).content ).decode("utf-8") user_answer_base64 = ImageToTextTask.ImageToTextTask( @@ -103,7 +107,7 @@ async def run(): resolve = await ImageToTextTask.aioImageToTextTask( anticaptcha_key=ANTICAPTCHA_KEY, save_format="const" ).captcha_handler( - captcha_link="http://85.255.8.26/static/image/common_image_example/800070.png" + captcha_link="https://pythoncaptcha.cloud/static/image/common_image_example/800070.png" ) print(resolve) @@ -144,7 +148,8 @@ async def run(): """ answer = requests.post( - "http://85.255.8.26:8001/register_key", json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"} + "https://pythoncaptcha.cloud:8001/register_key", + json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"}, ) # если очередь успешно создана: if answer == "OK": @@ -152,9 +157,9 @@ async def run(): # создаём задание с callbackURL параметром result = ImageToTextTask.ImageToTextTask( anticaptcha_key=ANTICAPTCHA_KEY, - callbackUrl=f"http://85.255.8.26:8001/anticaptcha/image_to_text/{QUEUE_KEY}", + callbackUrl=f"https://pythoncaptcha.cloud:8001/anticaptcha/image_to_text/{QUEUE_KEY}", ).captcha_handler( - captcha_link="http://85.255.8.26/static/image/common_image_example/800070.png" + captcha_link="https://pythoncaptcha.cloud/static/image/common_image_example/800070.png" ) print(result) diff --git a/anticaptcha_examples/anticaptcha_fun_example.py b/anticaptcha_examples/anticaptcha_fun_example.py index 4e2a2a7..815e9cd 100644 --- a/anticaptcha_examples/anticaptcha_fun_example.py +++ b/anticaptcha_examples/anticaptcha_fun_example.py @@ -70,7 +70,8 @@ async def run(): """ answer = requests.post( - "http://85.255.8.26:8001/register_key", json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"} + "https://pythoncaptcha.cloud:8001/register_key", + json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"}, ) # если очередь успешно создана: if answer == "OK": @@ -83,7 +84,7 @@ async def run(): proxyPort=8080, proxyLogin="proxyLoginHere", proxyPassword="proxyPasswordHere", - callbackUrl=f"http://85.255.8.26:8001/anticaptcha/fun_captcha/{QUEUE_KEY}", + callbackUrl=f"https://pythoncaptcha.cloud:8001/anticaptcha/fun_captcha/{QUEUE_KEY}", ).captcha_handler(websiteURL=WEB_URL, websitePublicKey=SITE_KEY) print(result) @@ -99,7 +100,7 @@ async def run(): # создаём задание с callbackURL параметром result = FunCaptchaTaskProxyless.FunCaptchaTaskProxyless( anticaptcha_key=ANTICAPTCHA_KEY, - callbackUrl=f"http://85.255.8.26:8001/anticaptcha/fun_captcha/{QUEUE_KEY}", + callbackUrl=f"https://pythoncaptcha.cloud:8001/anticaptcha/fun_captcha/{QUEUE_KEY}", ).captcha_handler(websiteURL=WEB_URL, websitePublicKey=SITE_KEY) print(result) diff --git a/anticaptcha_examples/anticaptcha_nocaptcha_example.py b/anticaptcha_examples/anticaptcha_nocaptcha_example.py index 3dd7426..09eeb76 100644 --- a/anticaptcha_examples/anticaptcha_nocaptcha_example.py +++ b/anticaptcha_examples/anticaptcha_nocaptcha_example.py @@ -73,7 +73,8 @@ async def run(): """ answer = requests.post( - "http://85.255.8.26:8001/register_key", json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"} + "https://pythoncaptcha.cloud:8001/register_key", + json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"}, ) # если очередь успешно создана: if answer == "OK": @@ -85,7 +86,7 @@ async def run(): proxyPort=8080, proxyLogin="proxyLoginHere", proxyPassword="proxyPasswordHere", - callbackUrl=f"http://85.255.8.26:8001/anticaptcha/nocaptcha/{QUEUE_KEY}", + callbackUrl=f"https://pythoncaptcha.cloud:8001/anticaptcha/nocaptcha/{QUEUE_KEY}", ).captcha_handler( websiteURL="https://www.google.com/recaptcha/api2/demo", websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", diff --git a/anticaptcha_examples/anticaptcha_square_net_task.py b/anticaptcha_examples/anticaptcha_square_net_task.py index 4bcb638..37c4e7a 100644 --- a/anticaptcha_examples/anticaptcha_square_net_task.py +++ b/anticaptcha_examples/anticaptcha_square_net_task.py @@ -57,14 +57,15 @@ async def run(): """ answer = requests.post( - "http://85.255.8.26:8001/register_key", json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"} + "https://pythoncaptcha.cloud:8001/register_key", + json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"}, ) # если очередь успешно создана: if answer == "OK": # создаём задание с callbackURL параметром result = SquareNetTextTask.SquareNetTextTask( anticaptcha_key=ANTICAPTCHA_KEY, - callbackUrl=f"http://85.255.8.26:8001/anticaptcha/fun_captcha/{QUEUE_KEY}", + callbackUrl=f"https://pythoncaptcha.cloud:8001/anticaptcha/fun_captcha/{QUEUE_KEY}", ).captcha_handler( objectName="captcha numbers", rowsCount=2, diff --git a/anticaptcha_examples/callback_examples.py b/anticaptcha_examples/callback_examples.py index bf4081a..f7917df 100644 --- a/anticaptcha_examples/callback_examples.py +++ b/anticaptcha_examples/callback_examples.py @@ -27,7 +27,8 @@ """ answer = requests.post( - "http://85.255.8.26:8001/register_key", json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"} + "https://pythoncaptcha.cloud:8001/register_key", + json={"key": QUEUE_KEY, "vhost": "anticaptcha_vhost"}, ) # если очередь успешно создана: if answer == "OK": @@ -36,7 +37,7 @@ # Это метод для работы без прокси result = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless( anticaptcha_key=ANTICAPTCHA_KEY, - callbackUrl=f"http://85.255.8.26:8001/anticaptcha/nocaptcha/{QUEUE_KEY}", + callbackUrl=f"https://pythoncaptcha.cloud:8001/anticaptcha/nocaptcha/{QUEUE_KEY}", ).captcha_handler( websiteURL="https://www.google.com/recaptcha/api2/demo", websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", @@ -52,11 +53,11 @@ ).captcha_handler( requests_timeout=0.5, auth_params={ - "host": "85.255.8.26", + "host": "https://pythoncaptcha.cloud/", "port": "8001", "rtmq_username": "hardworker_1", "rtmq_password": "password", - "rtmq_host": "85.255.8.26", + "rtmq_host": "https://pythoncaptcha.cloud/", "rtmq_port": "5672", "rtmq_vhost": "anticaptcha_vhost", }, @@ -68,7 +69,7 @@ async def run(): try: result = await NoCaptchaTaskProxyless.aioNoCaptchaTaskProxyless( anticaptcha_key=ANTICAPTCHA_KEY, - callbackUrl=f"http://85.255.8.26:8001/anticaptcha/nocaptcha/{QUEUE_KEY}", + callbackUrl=f"https://pythoncaptcha.cloud:8001/anticaptcha/nocaptcha/{QUEUE_KEY}", ).captcha_handler( websiteURL="https://www.google.com/recaptcha/api2/demo", websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",