Skip to content

Commit

Permalink
Refactor examples
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiDrang committed Mar 30, 2020
1 parent 171771c commit bddb5b2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
19 changes: 12 additions & 7 deletions anticaptcha_examples/anticaptcah_image_to_text_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -144,17 +148,18 @@ 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 = 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)

Expand Down
7 changes: 4 additions & 3 deletions anticaptcha_examples/anticaptcha_fun_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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)

Expand All @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions anticaptcha_examples/anticaptcha_nocaptcha_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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-",
Expand Down
5 changes: 3 additions & 2 deletions anticaptcha_examples/anticaptcha_square_net_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 6 additions & 5 deletions anticaptcha_examples/callback_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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-",
Expand All @@ -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",
},
Expand All @@ -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-",
Expand Down

0 comments on commit bddb5b2

Please sign in to comment.