Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
recaptcha_v2,
recaptcha_v3,
image_to_text,
prosopo_captcha,
friendly_captcha,
image_to_coordinates,
)
from python3_anticaptcha.__version__ import __version__
Expand Down
12 changes: 12 additions & 0 deletions docs/modules/friend/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FriendlyCaptcha
===============

To import this module:

.. code-block:: python

from python3_anticaptcha.friendly_captcha import FriendlyCaptcha


.. autoclass:: python3_anticaptcha.friendly_captcha.FriendlyCaptcha
:members:
12 changes: 12 additions & 0 deletions docs/modules/prosopo/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Prosopo
=======

To import this module:

.. code-block:: python

from python3_anticaptcha.prosopo_captcha import Prosopo


.. autoclass:: python3_anticaptcha.prosopo_captcha.Prosopo
:members:
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx==8.2.1
sphinx==8.3.0
pallets_sphinx_themes==2.3.0
myst-parser==4.0.1
2 changes: 1 addition & 1 deletion requirements.style.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# codestyle
isort==5.*
isort==6.*
black==25.*
autoflake==2.*
2 changes: 1 addition & 1 deletion src/python3_anticaptcha/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.1.3"
__version__ = "2.1.4"
6 changes: 6 additions & 0 deletions src/python3_anticaptcha/core/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class CaptchaTypeEnm(str, MyEnum):
# Turnstile
TurnstileTask = "TurnstileTask"
TurnstileTaskProxyless = "TurnstileTaskProxyless"
# FriendlyCaptcha
FriendlyCaptchaTask = "FriendlyCaptchaTask"
FriendlyCaptchaTaskProxyless = "FriendlyCaptchaTaskProxyless"
# FriendlyCaptcha
ProsopoTask = "ProsopoTask"
ProsopoTaskProxyless = "ProsopoTaskProxyless"
# Custom
AntiGateTask = "AntiGateTask"

Expand Down
146 changes: 146 additions & 0 deletions src/python3_anticaptcha/friendly_captcha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
from typing import Union, Optional

from .core.base import CaptchaParams
from .core.enum import ProxyTypeEnm, CaptchaTypeEnm

__all__ = ("FriendlyCaptcha",)


class FriendlyCaptcha(CaptchaParams):
def __init__(
self,
api_key: str,
websiteURL: str,
websiteKey: str,
captcha_type: Union[CaptchaTypeEnm, str] = CaptchaTypeEnm.FriendlyCaptchaTaskProxyless,
proxyType: Optional[Union[ProxyTypeEnm, str]] = None,
proxyAddress: Optional[str] = None,
proxyPort: Optional[int] = None,
proxyLogin: Optional[str] = None,
proxyPassword: Optional[str] = None,
userAgent: Optional[str] = None,
sleep_time: Optional[int] = 10,
):
"""
The class is used to work with FriendlyCaptcha.

Args:
api_key: Capsolver API key
captcha_type: Captcha type
websiteURL: Address of the webpage
websiteKey: Friendly Captcha sitekey
proxyType: Type of the proxy
proxyAddress: Proxy IP address IPv4/IPv6. Not allowed to use:
host names instead of IPs,
transparent proxies (where client IP is visible),
proxies from local networks (192.., 10.., 127...)
proxyPort: Proxy port.
proxyLogin: Proxy login.
proxyPassword: Proxy password.
userAgent: Browser UserAgent.
sleep_time: The waiting time between requests to get the result of the Captcha

Examples:
>>> FriendlyCaptcha(api_key="99d7d111a0111dc11184111c8bb111da",
... captcha_type="FriendlyCaptchaTaskProxyless",
... websiteURL="https://demo.arkoselabs.com",
... websiteKey="FCMDESUD3M34857N"
... ).captcha_handler()
{
"errorId": 0,
"errorCode": None,
"errorDescription": None,
"status":"ready",
"solution":{
"token":"0.Qz0.....f1",
"userAgent":"Mozilla/5.0 (Wind.....",
},
"cost": 0.002,
"ip": "46.53.249.230",
"createTime": 1679004358,
"endTime": 1679004368,
"solveCount": 0,
"taskId": 396687629
}

>>> await FriendlyCaptcha(api_key="99d7d111a0111dc11184111c8bb111da",
... captcha_type="FriendlyCaptchaTaskProxyless",
... websiteURL="https://demo.arkoselabs.com",
... websitePublicKey="DF9C4D87-CB7B-4062-9FEB-BADB6ADA61E6"
... ).aio_captcha_handler()
{
"errorId": 0,
"errorCode": None,
"errorDescription": None,
"status":"ready",
"solution":{
"token":"0.Qz0.....f1",
"userAgent":"Mozilla/5.0 (Wind.....",
},
"cost": 0.002,
"ip": "46.53.249.230",
"createTime": 1679004358,
"endTime": 1679004368,
"solveCount": 0,
"taskId": 396687629
}

>>> FriendlyCaptcha(api_key="99d7d111a0111dc11184111c8bb111da",
... captcha_type="FriendlyCaptchaTask",
... websiteURL="https://demo.arkoselabs.com",
... websitePublicKey="DF9C4D87-CB7B-4062-9FEB-BADB6ADA61E6",
... proxyType="http",
... proxyAddress="0.0.0.0",
... proxyPort=9988,
... proxyLogin="proxy_login",
... proxyPassword="proxy_password",
... userAgent="some_real_user_agent",
... ).captcha_handler()
{
"errorId": 0,
"errorCode": None,
"errorDescription": None,
"status":"ready",
"solution":{
"token":"0.Qz0.....f1",
"userAgent":"Mozilla/5.0 (Wind.....",
},
"cost": 0.002,
"ip": "46.53.249.230",
"createTime": 1679004358,
"endTime": 1679004368,
"solveCount": 0,
"taskId": 396687629
}

Notes
https://anti-captcha.com/apidoc/task-types/FriendlyCaptchaTask

https://anti-captcha.com/apidoc/task-types/FriendlyCaptchaTaskProxyless
"""
super().__init__(api_key=api_key, sleep_time=sleep_time)

# validation of the received parameters
if captcha_type == CaptchaTypeEnm.FriendlyCaptchaTask:
self.task_params = dict(
type=captcha_type,
websiteURL=websiteURL,
websiteKey=websiteKey,
proxyType=proxyType,
proxyAddress=proxyAddress,
proxyPort=proxyPort,
proxyLogin=proxyLogin,
proxyPassword=proxyPassword,
userAgent=userAgent,
)
elif captcha_type == CaptchaTypeEnm.FriendlyCaptchaTaskProxyless:
self.task_params = dict(
type=captcha_type,
websiteURL=websiteURL,
websiteKey=websiteKey,
)
else:
raise ValueError(
f"Invalid `captcha_type` parameter set for `{self.__class__.__name__}`, \
available - {CaptchaTypeEnm.FriendlyCaptchaTaskProxyless.value,CaptchaTypeEnm.FriendlyCaptchaTask.value}"
)
146 changes: 146 additions & 0 deletions src/python3_anticaptcha/prosopo_captcha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
from typing import Union, Optional

from .core.base import CaptchaParams
from .core.enum import ProxyTypeEnm, CaptchaTypeEnm

__all__ = ("Prosopo",)


class Prosopo(CaptchaParams):
def __init__(
self,
api_key: str,
websiteURL: str,
websiteKey: str,
captcha_type: Union[CaptchaTypeEnm, str] = CaptchaTypeEnm.ProsopoTaskProxyless,
proxyType: Optional[Union[ProxyTypeEnm, str]] = None,
proxyAddress: Optional[str] = None,
proxyPort: Optional[int] = None,
proxyLogin: Optional[str] = None,
proxyPassword: Optional[str] = None,
userAgent: Optional[str] = None,
sleep_time: Optional[int] = 10,
):
"""
The class is used to work with Prosopo captcha.

Args:
api_key: Capsolver API key
captcha_type: Captcha type
websiteURL: Address of the webpage
websiteKey: Prosopo sitekey
proxyType: Type of the proxy
proxyAddress: Proxy IP address IPv4/IPv6. Not allowed to use:
host names instead of IPs,
transparent proxies (where client IP is visible),
proxies from local networks (192.., 10.., 127...)
proxyPort: Proxy port.
proxyLogin: Proxy login.
proxyPassword: Proxy password.
userAgent: Browser UserAgent.
sleep_time: The waiting time between requests to get the result of the Captcha

Examples:
>>> Prosopo(api_key="99d7d111a0111dc11184111c8bb111da",
... captcha_type="ProsopoTaskProxyless",
... websiteURL="https://demo.arkoselabs.com",
... websiteKey="FCMDESUD3M34857N"
... ).captcha_handler()
{
"errorId": 0,
"errorCode": None,
"errorDescription": None,
"status":"ready",
"solution":{
"token":"0.Qz0.....f1",
"userAgent":"Mozilla/5.0 (Wind.....",
},
"cost": 0.002,
"ip": "46.53.249.230",
"createTime": 1679004358,
"endTime": 1679004368,
"solveCount": 0,
"taskId": 396687629
}

>>> await Prosopo(api_key="99d7d111a0111dc11184111c8bb111da",
... captcha_type="ProsopoTaskProxyless",
... websiteURL="https://demo.arkoselabs.com",
... websitePublicKey="DF9C4D87-CB7B-4062-9FEB-BADB6ADA61E6"
... ).aio_captcha_handler()
{
"errorId": 0,
"errorCode": None,
"errorDescription": None,
"status":"ready",
"solution":{
"token":"0.Qz0.....f1",
"userAgent":"Mozilla/5.0 (Wind.....",
},
"cost": 0.002,
"ip": "46.53.249.230",
"createTime": 1679004358,
"endTime": 1679004368,
"solveCount": 0,
"taskId": 396687629
}

>>> Prosopo(api_key="99d7d111a0111dc11184111c8bb111da",
... captcha_type="ProsopoTask",
... websiteURL="https://demo.arkoselabs.com",
... websitePublicKey="DF9C4D87-CB7B-4062-9FEB-BADB6ADA61E6",
... proxyType="http",
... proxyAddress="0.0.0.0",
... proxyPort=9988,
... proxyLogin="proxy_login",
... proxyPassword="proxy_password",
... userAgent="some_real_user_agent",
... ).captcha_handler()
{
"errorId": 0,
"errorCode": None,
"errorDescription": None,
"status":"ready",
"solution":{
"token":"0.Qz0.....f1",
"userAgent":"Mozilla/5.0 (Wind.....",
},
"cost": 0.002,
"ip": "46.53.249.230",
"createTime": 1679004358,
"endTime": 1679004368,
"solveCount": 0,
"taskId": 396687629
}

Notes
https://anti-captcha.com/apidoc/task-types/ProsopoTask

https://anti-captcha.com/apidoc/task-types/ProsopoTaskProxyless
"""
super().__init__(api_key=api_key, sleep_time=sleep_time)

# validation of the received parameters
if captcha_type == CaptchaTypeEnm.ProsopoTask:
self.task_params = dict(
type=captcha_type,
websiteURL=websiteURL,
websiteKey=websiteKey,
proxyType=proxyType,
proxyAddress=proxyAddress,
proxyPort=proxyPort,
proxyLogin=proxyLogin,
proxyPassword=proxyPassword,
userAgent=userAgent,
)
elif captcha_type == CaptchaTypeEnm.ProsopoTaskProxyless:
self.task_params = dict(
type=captcha_type,
websiteURL=websiteURL,
websiteKey=websiteKey,
)
else:
raise ValueError(
f"Invalid `captcha_type` parameter set for `{self.__class__.__name__}`, \
available - {CaptchaTypeEnm.ProsopoTaskProxyless.value,CaptchaTypeEnm.ProsopoTask.value}"
)
Loading