Add CustomCaptchaTask example and readme
This commit is contained in:
parent
51070d1ba0
commit
306f04466c
10
README.md
10
README.md
|
@ -118,7 +118,15 @@ print(user_answer)
|
||||||
|
|
||||||
Краткий пример:
|
Краткий пример:
|
||||||
```python
|
```python
|
||||||
|
from python3_anticaptcha import CustomCaptchaTask
|
||||||
|
# Введите ключ от сервиса AntiCaptcha, из своего аккаунта. Anticaptcha service key.
|
||||||
|
ANTICAPTCHA_KEY = ""
|
||||||
|
# ссылка на изображение
|
||||||
|
imageUrl = "https://files.anti-captcha.com/26/41f/c23/7c50ff19.jpg"
|
||||||
|
# минимальный пример использования модуля
|
||||||
|
my_custom_task = CustomCaptchaTask.CustomCaptchaTask(anticaptcha_key=ANTICAPTCHA_KEY).\
|
||||||
|
captcha_handler(imageUrl=imageUrl)
|
||||||
|
print(my_custom_task)
|
||||||
```
|
```
|
||||||
|
|
||||||
8.[Gee Test.](https://github.com/AndreiDrang/python3-anticaptcha/blob/master/anticaptcha_examples/anticaptcha_control_example.py)
|
8.[Gee Test.](https://github.com/AndreiDrang/python3-anticaptcha/blob/master/anticaptcha_examples/anticaptcha_control_example.py)
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
from python3_anticaptcha import CustomCaptchaTask
|
||||||
|
|
||||||
|
|
||||||
|
ANTICAPTCHA_KEY = ""
|
||||||
|
|
||||||
|
# Пример с созданием CustomCaptcha
|
||||||
|
|
||||||
|
# подробней - https://anticaptcha.atlassian.net/wiki/spaces/API/pages/241827850/CustomCaptchaTask
|
||||||
|
# ссылка на изображение
|
||||||
|
imageUrl = "https://files.anti-captcha.com/26/41f/c23/7c50ff19.jpg",
|
||||||
|
# кастомная форма для ответов пользователей
|
||||||
|
custom_form = '''[
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]'''
|
||||||
|
|
||||||
|
my_custom_task = CustomCaptchaTask.CustomCaptchaTask(anticaptcha_key=ANTICAPTCHA_KEY,
|
||||||
|
assignment='Enter license plate number',
|
||||||
|
forms=custom_form).\
|
||||||
|
captcha_handler(imageUrl=imageUrl)
|
||||||
|
|
||||||
|
|
||||||
|
print(my_custom_task)
|
||||||
|
|
||||||
|
|
||||||
|
# Асинхронный пример работы
|
||||||
|
async def run():
|
||||||
|
try:
|
||||||
|
# Пример работы антикапчи с кастомной капчёй, асинхронно
|
||||||
|
result = CustomCaptchaTask.aioCustomCaptchaTask(anticaptcha_key=ANTICAPTCHA_KEY,
|
||||||
|
assignment='Enter license plate number',
|
||||||
|
forms=custom_form).\
|
||||||
|
captcha_handler(imageUrl=imageUrl)
|
||||||
|
|
||||||
|
print(result)
|
||||||
|
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.run_until_complete(run())
|
||||||
|
loop.close()
|
Loading…
Reference in New Issue