2019-01-10 19:08:57 +00:00
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
|
|
from python3_anticaptcha import CustomCaptchaTask
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ANTICAPTCHA_KEY = ""
|
|
|
|
|
|
2019-03-19 19:26:12 +00:00
|
|
|
|
# Пример с созданием CustomCaptcha
|
2019-01-10 19:08:57 +00:00
|
|
|
|
|
|
|
|
|
# подробней - https://anticaptcha.atlassian.net/wiki/spaces/API/pages/241827850/CustomCaptchaTask
|
|
|
|
|
# ссылка на изображение
|
2019-01-10 19:10:30 +00:00
|
|
|
|
imageUrl = "https://files.anti-captcha.com/26/41f/c23/7c50ff19.jpg"
|
2019-01-10 19:08:57 +00:00
|
|
|
|
# кастомная форма для ответов пользователей
|
2019-03-19 19:26:12 +00:00
|
|
|
|
custom_form = """[
|
2019-01-10 19:08:57 +00:00
|
|
|
|
{
|
|
|
|
|
"label": "Number",
|
|
|
|
|
"labelHint": false,
|
|
|
|
|
"contentType": false,
|
|
|
|
|
"name": "license_plate",
|
|
|
|
|
"inputType": "text",
|
|
|
|
|
"inputOptions": {
|
|
|
|
|
"width": "100",
|
|
|
|
|
"placeHolder": "Enter a letters and number without spaces"
|
|
|
|
|
}
|
|
|
|
|
},{
|
|
|
|
|
"label": "Car color",
|
|
|
|
|
"labelHint": "Select color of the car",
|
|
|
|
|
"name": "color",
|
|
|
|
|
"inputType": "select",
|
|
|
|
|
"inputOptions": [
|
|
|
|
|
{
|
|
|
|
|
"value": "white",
|
|
|
|
|
"caption": "White color"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"value": "black",
|
|
|
|
|
"caption": "Black color"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"value": "grey",
|
|
|
|
|
"caption": "Grey color"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"value": "blue",
|
|
|
|
|
"caption": "Blue color"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"value": "red",
|
|
|
|
|
"caption": "Red color"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2019-03-19 19:26:12 +00:00
|
|
|
|
]"""
|
2019-01-10 19:08:57 +00:00
|
|
|
|
|
2019-03-19 19:26:12 +00:00
|
|
|
|
my_custom_task = CustomCaptchaTask.CustomCaptchaTask(
|
2019-11-25 17:08:18 +00:00
|
|
|
|
anticaptcha_key=ANTICAPTCHA_KEY, assignment="Enter license plate number", forms=custom_form
|
2019-03-19 19:26:12 +00:00
|
|
|
|
).captcha_handler(imageUrl=imageUrl)
|
2019-01-10 19:08:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(my_custom_task)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Асинхронный пример работы
|
|
|
|
|
async def run():
|
|
|
|
|
try:
|
|
|
|
|
# Пример работы антикапчи с кастомной капчёй, асинхронно
|
2019-03-19 19:26:12 +00:00
|
|
|
|
result = CustomCaptchaTask.aioCustomCaptchaTask(
|
|
|
|
|
anticaptcha_key=ANTICAPTCHA_KEY,
|
|
|
|
|
assignment="Enter license plate number",
|
|
|
|
|
forms=custom_form,
|
|
|
|
|
).captcha_handler(imageUrl=imageUrl)
|
|
|
|
|
|
2019-01-10 19:08:57 +00:00
|
|
|
|
print(result)
|
|
|
|
|
|
|
|
|
|
except Exception as err:
|
|
|
|
|
print(err)
|
|
|
|
|
|
|
|
|
|
|
2019-03-19 19:26:12 +00:00
|
|
|
|
if __name__ == "__main__":
|
2019-01-10 19:08:57 +00:00
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|
loop.run_until_complete(run())
|
|
|
|
|
loop.close()
|