2017-10-13 22:38:07 +00:00
# python3-anticaptcha
2017-10-11 18:36:36 +00:00
2018-05-15 11:12:20 +00:00
[![PyPI version ](https://badge.fury.io/py/python3-anticaptcha.svg )](https://badge.fury.io/py/python3-anticaptcha)
2019-10-07 01:29:17 +00:00
[![Python versions ](https://img.shields.io/pypi/pyversions/python3-anticaptcha.svg?logo=python&logoColor=FBE072 )](https://badge.fury.io/py/python3-anticaptcha)
2018-12-02 09:31:34 +00:00
[![Build Status ](https://semaphoreci.com/api/v1/andreidrang/python3-anticaptcha/branches/master/shields_badge.svg )](https://semaphoreci.com/andreidrang/python3-anticaptcha)
2019-10-06 22:13:19 +00:00
[![Build Status ](https://travis-ci.org/AndreiDrang/python3-anticaptcha.svg?branch=master )](https://travis-ci.org/AndreiDrang/python3-anticaptcha)
2018-05-15 11:12:20 +00:00
[![Code Climate ](https://codeclimate.com/github/AndreiDrang/python3-anticaptcha/badges/gpa.svg )](https://codeclimate.com/github/AndreiDrang/python3-anticaptcha)
2019-02-13 22:58:57 +00:00
[![Codacy Badge ](https://api.codacy.com/project/badge/Grade/2daabf7ff7974f01b9348fe64483c7af )](https://app.codacy.com/app/drang.andray/python3-anticaptcha?utm_source=github.com& utm_medium=referral& utm_content=AndreiDrang/python3-anticaptcha& utm_campaign=Badge_Grade_Settings)
2020-03-30 00:54:23 +00:00
2018-05-15 11:12:20 +00:00
2020-11-10 22:22:58 +00:00
Python 3.6+ library for [Anti-Captcha ](https://anti-captcha.com/mainpage ) service.
2017-10-11 18:36:36 +00:00
2018-04-21 23:18:17 +00:00
[Application in AppCenter ](https://anti-captcha.com/clients/tools/appcenter/app/867 ).
2017-10-22 17:18:37 +00:00
Tested on UNIX based OS.
2020-11-10 22:22:58 +00:00
The library is intended for software developers and is used to work with the AntiCaptcha service API.
2017-10-11 18:36:36 +00:00
## How to install? Как установить?
### pip
```bash
2017-10-13 22:37:37 +00:00
pip install python3-anticaptcha
2017-10-11 18:36:36 +00:00
```
### Source
```bash
2017-10-13 22:37:37 +00:00
git clone https://github.com/AndreiDrang/python3-anticaptcha.git
cd python3-anticaptcha
2017-10-11 18:36:36 +00:00
python setup.py install
```
***
2020-03-07 23:43:06 +00:00
По всем вопросам можете писать в [Telegram ](https://t.me/pythoncaptcha ) чат.
2017-12-15 11:24:20 +00:00
2020-03-07 23:43:06 +00:00
With any questions, please contact us in [Telegram ](https://t.me/pythoncaptcha ).
2017-10-11 18:36:36 +00:00
***
2020-03-30 00:45:48 +00:00
Присутствуют [примеры работы с библиотекой ](./anticaptcha_examples ).
2017-12-15 11:24:20 +00:00
2020-03-30 00:45:48 +00:00
Full examples you can find [here ](./anticaptcha_examples ).
2017-12-15 11:24:20 +00:00
***
### At the moment the following methods are implemented:
2017-10-11 18:36:36 +00:00
### Н а данный момент реализованы следующие методы:
2017-10-25 21:22:38 +00:00
2020-03-30 00:54:23 +00:00
##### 0.[Manual result handler.](./anticaptcha_examples/custom_result_handler_example.py)
2019-09-11 01:09:38 +00:00
```python
from python3_anticaptcha import CustomResultHandler
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
2020-03-30 00:45:48 +00:00
ANTICAPTCHA_KEY = "your_key"
2019-09-11 01:09:38 +00:00
# Task ID to get result
TASK_ID = 123456
# This module is used to obtain the result of solving the task in "manual" mode
custom_result = CustomResultHandler.CustomResultHandler(
anticaptcha_key=ANTICAPTCHA_KEY
)
user_answer = custom_result.task_handler(task_id=TASK_ID)
print(user_answer)
```
2020-03-30 00:54:23 +00:00
##### 1.[Image to text captcha.](./anticaptcha_examples/anticaptcah_image_to_text_example.py)
2017-10-25 21:22:38 +00:00
2019-08-20 15:09:16 +00:00
2017-10-25 21:22:38 +00:00
```python
from python3_anticaptcha import ImageToTextTask
2019-09-11 01:09:38 +00:00
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
2017-10-25 21:22:38 +00:00
ANTICAPTCHA_KEY = ""
2020-11-10 22:22:58 +00:00
# Link to captcha image.
2020-06-15 01:00:35 +00:00
image_link = "https://pythoncaptcha.tech/static/image/common_image_example/800070.png"
2020-11-10 22:22:58 +00:00
# Get string for solve captcha, and some other info.
2019-01-10 21:58:27 +00:00
user_answer = ImageToTextTask.ImageToTextTask(anticaptcha_key = ANTICAPTCHA_KEY).\
captcha_handler(captcha_link=image_link)
2017-10-25 21:22:38 +00:00
print(user_answer)
```
2020-03-30 00:54:23 +00:00
##### 2.[ReCaptcha v2.](./anticaptcha_examples/anticaptcha_nocaptcha_example.py)
2017-10-25 21:22:38 +00:00
2020-03-30 00:54:23 +00:00
##### 3.[ReCaptcha v2 Proxyless. ](./anticaptcha_examples/anticaptcha_nocaptcha_example.py) + [Selenium example](./anticaptcha_examples/selenium_recaptcha_v2.py)
2017-10-25 21:22:38 +00:00
```python
from python3_anticaptcha import NoCaptchaTaskProxyless
2019-09-11 01:09:38 +00:00
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
2017-10-25 21:22:38 +00:00
ANTICAPTCHA_KEY = ""
2017-12-15 11:24:20 +00:00
# G-ReCaptcha ключ сайта. Website google key.
2017-10-25 21:22:38 +00:00
SITE_KEY = '6LeuMjIUAAAAAODtAglF13UiJys0y05EjZugej6b'
2020-11-10 22:22:58 +00:00
# Page url.
2017-10-25 21:22:38 +00:00
PAGE_URL = 'https://www.google.com/recaptcha/intro/android.html'
2020-11-10 22:22:58 +00:00
# Get string for solve captcha, and other info.
2017-10-29 21:13:32 +00:00
user_answer = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key = ANTICAPTCHA_KEY)\
2019-01-10 21:58:27 +00:00
.captcha_handler(websiteURL=PAGE_URL,
websiteKey=SITE_KEY)
2017-10-25 21:22:38 +00:00
print(user_answer)
```
2020-03-30 00:54:23 +00:00
##### 4.[ReCaptcha v3 Proxyless. ](./anticaptcha_examples/anticaptcha_nocaptcha_example.py)
2019-07-20 19:11:31 +00:00
```python
from python3_anticaptcha import ReCaptchaV3TaskProxyless
2019-09-11 01:09:38 +00:00
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
2019-07-20 19:11:31 +00:00
ANTICAPTCHA_KEY = ""
2020-11-10 22:22:58 +00:00
# G-ReCaptcha - website google key.
2019-07-20 19:11:31 +00:00
SITE_KEY = '6LeuMjIUAAAAAODtAglF13UiJys0y05EjZugej6b'
2020-11-10 22:22:58 +00:00
# Page url.
2019-07-20 19:11:31 +00:00
PAGE_URL = 'https://some_link'
2020-11-10 22:22:58 +00:00
# The filter by which the employee with the required minimum score is selected.
# possible options - 0.3, 0.5, 0.7
2019-07-20 19:11:31 +00:00
MIN_SCORE=0.3
2020-11-10 22:22:58 +00:00
# The value of the `action` parameter, which is passed by the recaptcha widget to google.
2019-07-20 19:11:31 +00:00
PAGE_ACTION='login'
2020-11-10 22:22:58 +00:00
# Get string for solve captcha, and other info.
2019-07-20 19:11:31 +00:00
user_answer = ReCaptchaV3TaskProxyless.ReCaptchaV3TaskProxyless(anticaptcha_key = ANTICAPTCHA_KEY)\
.captcha_handler(websiteURL=PAGE_URL,
2020-03-30 00:45:48 +00:00
websiteKey=SITE_KEY,
2019-07-20 19:11:31 +00:00
minScore=MIN_SCORE,
pageAction=PAGE_ACTION
)
print(user_answer)
```
2020-03-30 00:54:23 +00:00
##### 5.[Fun Captcha.](./anticaptcha_examples/anticaptcha_fun_example.py)
2019-01-10 17:11:02 +00:00
2020-03-30 00:54:23 +00:00
##### 6.[Fun Captcha Proxyless.](./anticaptcha_examples/anticaptcha_fun_example.py)
2017-10-25 21:22:38 +00:00
```python
from python3_anticaptcha import FunCaptchaTask
2019-09-11 01:09:38 +00:00
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
2017-10-25 21:22:38 +00:00
ANTICAPTCHA_KEY = ""
2020-11-10 22:22:58 +00:00
# G-ReCaptcha site key
2017-10-25 21:22:38 +00:00
SITE_KEY = ''
2020-11-10 22:22:58 +00:00
# Link to the page with captcha
2017-10-25 21:22:38 +00:00
PAGE_URL = ''
2020-11-10 22:22:58 +00:00
# Get full data for solve captcha.
2017-10-25 21:22:38 +00:00
user_answer = FunCaptchaTask.FunCaptchaTask(anticaptcha_key=ANTICAPTCHA_KEY,
2017-10-29 21:13:32 +00:00
proxyType="http",
2017-10-25 21:22:38 +00:00
proxyAddress="8.8.8.8",
2017-10-29 21:13:32 +00:00
proxyPort=8080)\
2019-01-10 21:58:27 +00:00
.captcha_handler(websiteURL=PAGE_URL,
websitePublicKey=SITE_KEY)
2017-10-25 21:22:38 +00:00
print(user_answer)
```
2020-03-30 00:54:23 +00:00
##### 7.[Account management module.](./anticaptcha_examples/anticaptcha_control_example.py)
2017-10-25 21:22:38 +00:00
```python
from python3_anticaptcha import AntiCaptchaControl
2019-09-11 01:09:38 +00:00
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
2017-10-25 21:22:38 +00:00
ANTICAPTCHA_KEY = ""
2020-11-10 22:22:58 +00:00
# Balance info
result = AntiCaptchaControl.AntiCaptchaControl(anticaptcha_key = ANTICAPTCHA_KEY).get_balance()
# Submitting a complaint about incorrectly resolved captcha images
result = AntiCaptchaControl.AntiCaptchaControl(anticaptcha_key = ANTICAPTCHA_KEY).complaint_on_result(
reported_id=543212, captcha_type="image"
)
# Submitting a complaint about incorrectly resolved ReCaptcha
result = AntiCaptchaControl.AntiCaptchaControl(anticaptcha_key = ANTICAPTCHA_KEY).complaint_on_result(
reported_id=5432134, captcha_type="recaptcha"
)
# Giving information about loading the queue, depending on the queue ID
result = AntiCaptchaControl.AntiCaptchaControl(anticaptcha_key = ANTICAPTCHA_KEY).get_queue_status(queue_id=1)
2017-10-25 21:22:38 +00:00
```
2019-01-10 17:11:02 +00:00
2020-03-30 00:54:23 +00:00
##### 8.[Custom Captcha.](./anticaptcha_examples/anticaptcha_customcaptcha_example.py)
2019-01-10 17:11:02 +00:00
```python
2019-01-10 19:08:57 +00:00
from python3_anticaptcha import CustomCaptchaTask
2019-09-11 01:09:38 +00:00
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
2019-01-10 19:08:57 +00:00
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)
2019-01-10 17:11:02 +00:00
```
2020-03-30 00:54:23 +00:00
##### 9.[Gee Test.](./anticaptcha_examples/gee_example.py)
2019-01-10 17:11:02 +00:00
2020-03-30 00:54:23 +00:00
##### 10.[Gee Test Proxyless.](./anticaptcha_examples/gee_example.py)
2019-01-10 21:58:27 +00:00
2019-01-10 17:11:02 +00:00
```python
2019-01-10 21:58:27 +00:00
from python3_anticaptcha import GeeTestTaskProxyless
2019-09-11 01:09:38 +00:00
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
2019-01-10 21:58:27 +00:00
ANTICAPTCHA_KEY = ""
# обязательные параметры
websiteURL = "http:\/\/mywebsite.com\/geetest\/test.php"
gt = "874703612e5cac182812a00e273aad0d"
challenge = "a559b82bca2c500101a1c8a4f4204742"
# пример работы с GeeTestTask без прокси
result = GeeTestTaskProxyless.GeeTestTaskProxyless(anticaptcha_key=ANTICAPTCHA_KEY,
websiteURL=websiteURL,
gt=gt).\
captcha_handler(challenge=challenge)
2020-03-30 00:45:48 +00:00
print(result)
```
2020-03-30 00:54:23 +00:00
##### 11.[HCaptcha.](./anticaptcha_examples/anticaptcha_hcaptcha_example.py)
2020-03-30 00:45:48 +00:00
2020-03-30 00:54:23 +00:00
##### 12.[HCaptcha Proxyless.](./anticaptcha_examples/anticaptcha_hcaptcha_example.py)
2020-03-30 00:45:48 +00:00
```python
from python3_anticaptcha import HCaptchaTaskProxyless
# Enter the key to the AntiCaptcha service from your account. Anticaptcha service key.
ANTICAPTCHA_KEY = ""
WEB_URL = "https://dashboard.hcaptcha.com/signup"
SITE_KEY = "00000000-0000-0000-0000-000000000000"
result = HCaptchaTaskProxyless.HCaptchaTaskProxyless(anticaptcha_key=ANTICAPTCHA_KEY).\
captcha_handler(websiteURL=WEB_URL, websiteKey=SITE_KEY)
2019-01-10 21:58:27 +00:00
print(result)
2019-01-10 17:11:02 +00:00
```
2017-10-11 18:36:36 +00:00
***
2020-06-15 01:00:35 +00:00
Кроме того, для тестирования различных типов капчи предоставляется [специальный сайт ](https://pythoncaptcha.tech/ ), на котором собраны все имеющиеся типы капчи, с удобной системой тестирования ваших скриптов.
2017-10-25 21:22:38 +00:00
2020-06-15 01:00:35 +00:00
Some examples you can test with our [web-site ](https://pythoncaptcha.tech/ ).
2019-10-04 23:24:44 +00:00
***
2020-03-30 00:54:23 +00:00
#### For tests:
2019-10-04 23:24:44 +00:00
1. Clon repo;
2. ```bash
export anticaptcha_key=SERVICE_KEY
2020-11-10 21:47:23 +00:00
make test
2019-10-04 23:24:44 +00:00
```