Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upd #171

Merged
merged 25 commits into from
Oct 5, 2024
Merged

upd #171

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
4 changes: 2 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ omit =
*/tests/*

include =
*/src/python3_anticaptcha/*
*/src/*


[report]
Expand All @@ -13,4 +13,4 @@ omit =
*/tests/*

include =
*/src/python3_anticaptcha/*
*/src/*
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.test.txt
pip install -U -r requirements.test.txt

- name: Test
run: make tests
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ remove:
pip3 uninstall python3_anticaptcha -y

tests: install
coverage run --rcfile=.coveragerc -m pytest --verbose --showlocals --pastebin=all tests --disable-warnings && \
coverage run --rcfile=.coveragerc -m pytest --verbose --showlocals --pastebin=all --disable-warnings \
tests/ && \
coverage report --precision=3 --sort=cover --skip-empty --show-missing && \
coverage html --precision=3 --skip-empty -d coverage/html/ && \
coverage xml -o coverage/coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
for x in os.walk("src/python3_anticaptcha/"):
sys.path.insert(0, x[0])

from python3_anticaptcha import core, control, turnstile
from python3_anticaptcha import core, control, turnstile, image_captcha
from python3_anticaptcha.__version__ import __version__

# -- Project information -----------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions docs/modules/enum/info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ To import this module:
.. autoclass:: core.enum.ControlPostfixEnm
:members:
:undoc-members:

.. autoclass:: core.enum.SaveFormatsEnm
:members:
:undoc-members:
12 changes: 12 additions & 0 deletions docs/modules/image/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ImageToTextCaptcha
==================

To import this module:

.. code-block:: python

from python3_anticaptcha.image_captcha import ImageToTextCaptcha


.. autoclass:: python3_anticaptcha.image_captcha.ImageToTextCaptcha
:members:
Binary file added files/captcha-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions requirements.test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pytest==8.*
coverage==7.*
pytest-asyncio==0.*
pytest-mock==3.14.0
408 changes: 0 additions & 408 deletions src/python3_anticaptcha/ImageToTextTask.py

This file was deleted.

1 change: 0 additions & 1 deletion src/python3_anticaptcha/NoCaptchaTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def __exit__(self, exc_type, exc_value, traceback):
return False
return True

# Работа с капчей
def captcha_handler(self, websiteURL: str, websiteKey: str, recaptchaDataSValue: str = "", **kwargs) -> dict:
"""
Метод получает ссылку на страницу, где расположена капча, и ключ капчи
Expand Down
34 changes: 17 additions & 17 deletions src/python3_anticaptcha/control.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from .core.base import BaseCaptcha
from .core.enum import CaptchaTypeEnm, ControlPostfixEnm
from .core.enum import ControlPostfixEnm


class Control(BaseCaptcha):
Expand All @@ -16,7 +16,6 @@ def __init__(

Args:
api_key: Capsolver API key
captcha_type: Captcha type
websiteURL: Address of the webpage
websiteKey: Turnstile sitekey
proxyType: Type of the proxy
Expand Down Expand Up @@ -113,7 +112,7 @@ def __init__(
https://anti-captcha.com/apidoc/methods/reportIncorrectImageCaptcha
"""

super().__init__(api_key=api_key, captcha_type=CaptchaTypeEnm.Control, *args, **kwargs)
super().__init__(api_key=api_key, *args, **kwargs)

def get_balance(self) -> dict:
"""
Expand All @@ -135,7 +134,7 @@ def get_balance(self) -> dict:
return self._send_post_request(
session=self._session,
url_postfix=ControlPostfixEnm.GET_BALANCE,
payload={"clientKey": self._params.clientKey},
payload={"clientKey": self.create_task_payload.clientKey},
)

async def aio_get_balance(self) -> dict:
Expand All @@ -157,7 +156,7 @@ async def aio_get_balance(self) -> dict:
"""

return await self._aio_send_post_request(
url_postfix=ControlPostfixEnm.GET_BALANCE, payload={"clientKey": self._params.clientKey}
url_postfix=ControlPostfixEnm.GET_BALANCE, payload={"clientKey": self.create_task_payload.clientKey}
)

@staticmethod
Expand Down Expand Up @@ -290,7 +289,7 @@ def get_spending_stats(self, **kwargs) -> dict:
return self._send_post_request(
session=self._session,
url_postfix=ControlPostfixEnm.GET_SPENDING_STATS,
payload={"clientKey": self._params.clientKey, **kwargs},
payload={"clientKey": self.create_task_payload.clientKey, **kwargs},
)

async def aio_get_spending_stats(self, **kwargs) -> dict:
Expand Down Expand Up @@ -345,7 +344,8 @@ async def aio_get_spending_stats(self, **kwargs) -> dict:
https://anti-captcha.com/apidoc/methods/getSpendingStats
"""
return await self._aio_send_post_request(
url_postfix=ControlPostfixEnm.GET_SPENDING_STATS, payload={"clientKey": self._params.clientKey, **kwargs}
url_postfix=ControlPostfixEnm.GET_SPENDING_STATS,
payload={"clientKey": self.create_task_payload.clientKey, **kwargs},
)

def get_app_stats(self, softId: int, mode: Optional[str] = None) -> dict:
Expand Down Expand Up @@ -388,7 +388,7 @@ def get_app_stats(self, softId: int, mode: Optional[str] = None) -> dict:
return self._send_post_request(
session=self._session,
url_postfix=ControlPostfixEnm.GET_APP_STATS,
payload={"clientKey": self._params.clientKey, "softId": softId, "mode": mode},
payload={"clientKey": self.create_task_payload.clientKey, "softId": softId, "mode": mode},
)

async def aio_get_app_stats(self, softId: int, mode: Optional[str] = None) -> dict:
Expand Down Expand Up @@ -430,7 +430,7 @@ async def aio_get_app_stats(self, softId: int, mode: Optional[str] = None) -> di

return await self._aio_send_post_request(
url_postfix=ControlPostfixEnm.GET_APP_STATS,
payload={"clientKey": self._params.clientKey, "softId": softId, "mode": mode},
payload={"clientKey": self.create_task_payload.clientKey, "softId": softId, "mode": mode},
)

def report_incorrect_image(self, taskId: int) -> dict:
Expand All @@ -455,7 +455,7 @@ def report_incorrect_image(self, taskId: int) -> dict:
return self._send_post_request(
session=self._session,
url_postfix=ControlPostfixEnm.REPORT_INCORRECT_IMAGE_CAPTCHA,
payload={"clientKey": self._params.clientKey, "taskId": taskId},
payload={"clientKey": self.create_task_payload.clientKey, "taskId": taskId},
)

async def aio_report_incorrect_image(self, taskId: int) -> dict:
Expand All @@ -479,7 +479,7 @@ async def aio_report_incorrect_image(self, taskId: int) -> dict:

return await self._aio_send_post_request(
url_postfix=ControlPostfixEnm.REPORT_INCORRECT_IMAGE_CAPTCHA,
payload={"clientKey": self._params.clientKey, "taskId": taskId},
payload={"clientKey": self.create_task_payload.clientKey, "taskId": taskId},
)

def report_incorrect_recaptcha(self, taskId: int) -> dict:
Expand All @@ -504,7 +504,7 @@ def report_incorrect_recaptcha(self, taskId: int) -> dict:
return self._send_post_request(
session=self._session,
url_postfix=ControlPostfixEnm.REPORT_INCORRECT_RECAPTCHA,
payload={"clientKey": self._params.clientKey, "taskId": taskId},
payload={"clientKey": self.create_task_payload.clientKey, "taskId": taskId},
)

async def aio_report_incorrect_recaptcha(self, taskId: int) -> dict:
Expand All @@ -527,7 +527,7 @@ async def aio_report_incorrect_recaptcha(self, taskId: int) -> dict:
"""
return await self._aio_send_post_request(
url_postfix=ControlPostfixEnm.REPORT_INCORRECT_RECAPTCHA,
payload={"clientKey": self._params.clientKey, "taskId": taskId},
payload={"clientKey": self.create_task_payload.clientKey, "taskId": taskId},
)

def report_correct_recaptcha(self, taskId: int) -> dict:
Expand All @@ -552,7 +552,7 @@ def report_correct_recaptcha(self, taskId: int) -> dict:
return self._send_post_request(
session=self._session,
url_postfix=ControlPostfixEnm.REPORT_CORRECT_RECAPTCHA,
payload={"clientKey": self._params.clientKey, "taskId": taskId},
payload={"clientKey": self.create_task_payload.clientKey, "taskId": taskId},
)

async def aio_report_correct_recaptcha(self, taskId: int) -> dict:
Expand All @@ -575,7 +575,7 @@ async def aio_report_correct_recaptcha(self, taskId: int) -> dict:
"""
return await self._aio_send_post_request(
url_postfix=ControlPostfixEnm.REPORT_CORRECT_RECAPTCHA,
payload={"clientKey": self._params.clientKey, "taskId": taskId},
payload={"clientKey": self.create_task_payload.clientKey, "taskId": taskId},
)

def report_incorrect_hcaptcha(self, taskId: int) -> dict:
Expand All @@ -600,7 +600,7 @@ def report_incorrect_hcaptcha(self, taskId: int) -> dict:
return self._send_post_request(
session=self._session,
url_postfix=ControlPostfixEnm.REPORT_INCORRECT_HCAPTCHA,
payload={"clientKey": self._params.clientKey, "taskId": taskId},
payload={"clientKey": self.create_task_payload.clientKey, "taskId": taskId},
)

async def aio_report_incorrect_hcaptcha(self, taskId: int) -> dict:
Expand All @@ -623,5 +623,5 @@ async def aio_report_incorrect_hcaptcha(self, taskId: int) -> dict:
"""
return await self._aio_send_post_request(
url_postfix=ControlPostfixEnm.REPORT_INCORRECT_HCAPTCHA,
payload={"clientKey": self._params.clientKey, "taskId": taskId},
payload={"clientKey": self.create_task_payload.clientKey, "taskId": taskId},
)
Loading
Loading