Validate and display captcha from Arcaptcha easily in Python. (PyPI)
Install using pip:
pip install arcaptcha-python
Install manually:
git clone [email protected]:arcaptcha/arcaptcha-python.git
cd arcaptcha-python
sudo python setup.py install
Before doing anything, please read the documentation.
>>> from arcaptcha_python import Arcaptcha
>>> # Create a new instance of Captcha object
>>> captcha = Arcaptcha.Captcha(site_key = "my_site_key", secret_key = "my_secret_key")
>>> # Verify challenge
>>> captcha.verify(response = "example_challenge_id")
True
>>> # Display API script tag
>>> captcha.display_tag()
"<script src='https://widget.arcaptcha.co/2/api.js' async defer></script>"
>>> # Display captcha HTML tag
>>> captcha.displayCaptcha()
'<div class="arcaptcha" data-site-key="my_site_key" data-size="normal" data-theme="light" data-lang="fa"></div>'
You can use the following functions with captcha
:
Function | Parameters | Description |
---|---|---|
display_tag() | Display ARCaptcha javascript resource HTML code. | |
displayWithColor() | color | Required | Display captcha HTML code with color |
displayWithLang() | lang | Optional(default: fa) | Display captcha HTML code with language |
displayWithTheme() | theme | Optional(default: light) | Display captcha HTML code with theme |
displayWithCallBack() | callback | Required | Display captcha HTML code with callback |
displayWithSize() | size | Optional(default: normal) | Display captcha HTML code with size |
displayCaptcha() | size, callback(default: None), theme, color(default: None),lang | Display captcha HTML code with all parameter. |