python3-capsolver 1.0.0a0__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {python3_capsolver-1.0.0a0/src/python3_capsolver.egg-info → python3_capsolver-1.0.1}/PKG-INFO +2 -1
  2. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/README.md +1 -0
  3. python3_capsolver-1.0.1/src/python3_capsolver/__version__.py +1 -0
  4. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/cloudflare.py +36 -0
  5. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/base.py +9 -8
  6. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/serializer.py +1 -1
  7. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/datadome_slider.py +22 -0
  8. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/friendly_captcha.py +36 -0
  9. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/image_to_text.py +3 -3
  10. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/mt_captcha.py +17 -0
  11. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/vision_engine.py +3 -3
  12. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/yandex.py +23 -3
  13. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1/src/python3_capsolver.egg-info}/PKG-INFO +2 -1
  14. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver.egg-info/SOURCES.txt +6 -1
  15. python3_capsolver-1.0.1/tests/test_aws_waf.py +115 -0
  16. python3_capsolver-1.0.0a0/tests/test_aws_waf.py → python3_capsolver-1.0.1/tests/test_cloudflare.py +7 -8
  17. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/tests/test_core.py +10 -10
  18. python3_capsolver-1.0.1/tests/test_datadome.py +33 -0
  19. python3_capsolver-1.0.1/tests/test_friendly.py +33 -0
  20. python3_capsolver-1.0.1/tests/test_vision_engine.py +23 -0
  21. python3_capsolver-1.0.1/tests/test_yandex.py +33 -0
  22. python3_capsolver-1.0.0a0/src/python3_capsolver/__version__.py +0 -1
  23. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/LICENSE +0 -0
  24. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/MANIFEST.in +0 -0
  25. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/pyproject.toml +0 -0
  26. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/setup.cfg +0 -0
  27. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/__init__.py +0 -0
  28. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/aws_waf.py +0 -0
  29. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/control.py +0 -0
  30. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/__init__.py +0 -0
  31. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/aio_captcha_instrument.py +0 -0
  32. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/captcha_instrument.py +0 -0
  33. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/const.py +0 -0
  34. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/context_instr.py +0 -0
  35. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/enum.py +0 -0
  36. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/sio_captcha_instrument.py +0 -0
  37. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/core/utils.py +0 -0
  38. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/gee_test.py +0 -0
  39. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver/recaptcha.py +0 -0
  40. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver.egg-info/dependency_links.txt +0 -0
  41. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver.egg-info/requires.txt +0 -0
  42. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/src/python3_capsolver.egg-info/top_level.txt +0 -0
  43. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/tests/test_control.py +0 -0
  44. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/tests/test_gee_test.py +0 -0
  45. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/tests/test_image_to_text.py +0 -0
  46. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/tests/test_instrument.py +0 -0
  47. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/tests/test_mt_captcha.py +0 -0
  48. {python3_capsolver-1.0.0a0 → python3_capsolver-1.0.1}/tests/test_recaptcha.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: python3-capsolver
3
- Version: 1.0.0a0
3
+ Version: 1.0.1
4
4
  Summary: Python 3.8+ Capsolver library with AIO module.
5
5
  Author-email: AndreiDrang <python-captcha@pm.me>
6
6
  License: MIT License
@@ -44,6 +44,7 @@ Requires-Dist: tenacity<10,>=8
44
44
  [![Downloads](https://static.pepy.tech/badge/python3-capsolver/month)](https://pepy.tech/project/python3-capsolver)
45
45
  [![Static Badge](https://img.shields.io/badge/docs-Sphinx-green?label=Documentation&labelColor=gray)](https://andreidrang.github.io/python3-capsolver/)
46
46
 
47
+ [![Maintainability](https://api.codeclimate.com/v1/badges/3c30167b5fb37a0775ea/maintainability)](https://codeclimate.com/github/AndreiDrang/python3-capsolver/maintainability)
47
48
  [![Codacy Badge](https://app.codacy.com/project/badge/Grade/323d4eda0fe1477bbea8fe8902b9e97e)](https://www.codacy.com/gh/AndreiDrang/python3-capsolver/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=AndreiDrang/python3-capsolver&amp;utm_campaign=Badge_Grade)
48
49
  [![codecov](https://codecov.io/gh/AndreiDrang/python3-capsolver/branch/main/graph/badge.svg?token=2L4VVIF4G8)](https://codecov.io/gh/AndreiDrang/python3-capsolver)
49
50
 
@@ -9,6 +9,7 @@
9
9
  [![Downloads](https://static.pepy.tech/badge/python3-capsolver/month)](https://pepy.tech/project/python3-capsolver)
10
10
  [![Static Badge](https://img.shields.io/badge/docs-Sphinx-green?label=Documentation&labelColor=gray)](https://andreidrang.github.io/python3-capsolver/)
11
11
 
12
+ [![Maintainability](https://api.codeclimate.com/v1/badges/3c30167b5fb37a0775ea/maintainability)](https://codeclimate.com/github/AndreiDrang/python3-capsolver/maintainability)
12
13
  [![Codacy Badge](https://app.codacy.com/project/badge/Grade/323d4eda0fe1477bbea8fe8902b9e97e)](https://www.codacy.com/gh/AndreiDrang/python3-capsolver/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=AndreiDrang/python3-capsolver&amp;utm_campaign=Badge_Grade)
13
14
  [![codecov](https://codecov.io/gh/AndreiDrang/python3-capsolver/branch/main/graph/badge.svg?token=2L4VVIF4G8)](https://codecov.io/gh/AndreiDrang/python3-capsolver)
14
15
 
@@ -0,0 +1 @@
1
+ __version__ = "1.0.1"
@@ -79,6 +79,42 @@ class Cloudflare(CaptchaParams):
79
79
  }
80
80
  }
81
81
 
82
+ >>> import asyncio
83
+ >>> from python3_capsolver.cloudflare import Cloudflare
84
+ >>> from python3_capsolver.core.enum import CaptchaTypeEnm
85
+ >>> asyncio.run(Cloudflare(api_key="CAI-12345....",
86
+ ... captcha_type=CaptchaTypeEnm.AntiCloudflareTask)
87
+ ... .aio_captcha_handler(task_payload={
88
+ ... "websiteURL": "https://www.yourwebsite.com",
89
+ ... "proxy": "ip:port:user:pass",
90
+ ... }))
91
+ {
92
+ "errorId":0,
93
+ "errorCode":"None",
94
+ "errorDescription":"None",
95
+ "taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
96
+ "status":"ready",
97
+ "solution":{
98
+ "cookies": "cf_clearance=_VPxxxx",
99
+ "headers": {
100
+ "sec-ch-ua": "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
101
+ "sec-ch-ua-platform": "\"Windows\"",
102
+ "accept": "text/html,axxxx",
103
+ "User-Agent": "Mozilla/5.0xxxx",
104
+ "sec-ch-ua-mobile": "?0",
105
+ "sec-fetch-user": "?1",
106
+ "referer": "https://www.yourwebsite.com",
107
+ "Sec-Fetch-Dest": "document",
108
+ "Sec-Fetch-Mode": "navigate",
109
+ "Sec-Fetch-Site": "same-origin",
110
+ "accept-language": "en",
111
+ },
112
+ "page_url": "https://www.yourwebsite.com",
113
+ "proxy": "your proxyxxxx",
114
+ "token": "_VPCTZXP5bhinxxxx"
115
+ }
116
+ }
117
+
82
118
  Notes:
83
119
  https://docs.capsolver.com/en/guide/captcha/cloudflare_turnstile/
84
120
 
@@ -1,4 +1,4 @@
1
- from typing import Dict
1
+ from typing import Any, Dict
2
2
 
3
3
  from python3_capsolver.core.enum import CaptchaTypeEnm
4
4
  from python3_capsolver.core.serializer import TaskSer
@@ -41,15 +41,15 @@ class CaptchaParams(SIOContextManager, AIOContextManager):
41
41
  self._captcha_handling_instrument = CaptchaInstrument()
42
42
  self.sleep_time = sleep_time
43
43
 
44
- def captcha_handler(self, task_payload: Dict) -> Dict[str, str]:
44
+ def captcha_handler(self, task_payload: Dict) -> Dict[str, Any]:
45
45
  """
46
46
  Synchronous method for captcha solving
47
47
 
48
48
  Args:
49
49
  task_payload: Some additional parameters that will be used in creating the task
50
- and will be passed to the payload under ``task`` key.
51
- Like ``proxyLogin``, ``proxyPassword`` and etc. - more info in service docs
52
-
50
+ and will be passed to the payload under ``task`` key.
51
+ Like ``websiteURL``, ``image``, ``proxyPassword``, ``websiteKey`` and etc.
52
+ more info in service docs
53
53
 
54
54
  Returns:
55
55
  Dict with full server response
@@ -61,14 +61,15 @@ class CaptchaParams(SIOContextManager, AIOContextManager):
61
61
  self._captcha_handling_instrument = SIOCaptchaInstrument(captcha_params=self)
62
62
  return self._captcha_handling_instrument.processing_captcha()
63
63
 
64
- async def aio_captcha_handler(self, task_payload: Dict) -> Dict[str, str]:
64
+ async def aio_captcha_handler(self, task_payload: Dict) -> Dict[str, Any]:
65
65
  """
66
66
  Asynchronous method for captcha solving
67
67
 
68
68
  Args:
69
69
  task_payload: Some additional parameters that will be used in creating the task
70
- and will be passed to the payload under ``task`` key.
71
- Like ``proxyLogin``, ``proxyPassword`` and etc. - more info in service docs
70
+ and will be passed to the payload under ``task`` key.
71
+ Like ``websiteURL``, ``image``, ``proxyPassword``, ``websiteKey`` and etc.
72
+ more info in service docs
72
73
 
73
74
  Returns:
74
75
  Dict with full server response
@@ -10,7 +10,7 @@ __all__ = ("PostRequestSer", "TaskSer", "RequestCreateTaskSer", "CaptchaResponse
10
10
 
11
11
 
12
12
  class MyBaseModel(Struct):
13
- def to_dict(self) -> Dict[str, str]:
13
+ def to_dict(self) -> Dict[str, Any]:
14
14
  result = {}
15
15
  for f in self.__struct_fields__:
16
16
  if isinstance(getattr(self, f), Enum):
@@ -39,6 +39,28 @@ class DatadomeSlider(CaptchaParams):
39
39
  }
40
40
  }
41
41
 
42
+ >>> import asyncio
43
+ >>> from python3_capsolver.datadome_slider import DatadomeSlider
44
+ >>> from python3_capsolver.core.enum import CaptchaTypeEnm
45
+ >>> asyncio.run(DatadomeSlider(api_key="CAI-12345....",
46
+ ... captcha_type=CaptchaTypeEnm.DatadomeSliderTask)
47
+ ... .aio_captcha_handler(task_payload={
48
+ ... "captchaUrl": "https://geo.captchaxxxxxx",
49
+ ... "userAgent": "Mozilla/5.0 xxxx",
50
+ ... "proxy": "0.0.0.0:334:user:pass"
51
+ ... }))
52
+ {
53
+ "errorId":0,
54
+ "errorCode":"None",
55
+ "errorDescription":"None",
56
+ "taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
57
+ "status":"ready",
58
+ "solution":{
59
+ "userAgent": "Mozilla/5.0 xxxx",
60
+ "cookie": "datadome=yzj_BK..xxxx"
61
+ }
62
+ }
63
+
42
64
  Notes:
43
65
  https://docs.capsolver.com/en/guide/captcha/datadome/
44
66
  """
@@ -55,6 +55,42 @@ class FriendlyCaptcha(CaptchaParams):
55
55
  }
56
56
  }
57
57
 
58
+ >>> import asyncio
59
+ >>> from python3_capsolver.core.enum import CaptchaTypeEnm
60
+ >>> from python3_capsolver.friendly_captcha import FriendlyCaptcha
61
+ >>> asyncio.run(FriendlyCaptcha(api_key="CAP-XXXXX",
62
+ ... captcha_type=CaptchaTypeEnm.FriendlyCaptchaTaskProxyless,
63
+ ... ).aio_captcha_handler(task_payload={
64
+ ... "websiteURL": "https://www.yourwebsite.com",
65
+ ... "proxy": "ip:port:user:pass"
66
+ ... }))
67
+ {
68
+ "errorId":0,
69
+ "errorCode":"None",
70
+ "errorDescription":"None",
71
+ "taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
72
+ "status":"ready",
73
+ "solution":{
74
+ "cookies": "cf_clearance=_VPxxxx",
75
+ "headers": {
76
+ "sec-ch-ua": "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
77
+ "sec-ch-ua-platform": "\"Windows\"",
78
+ "accept": "text/html,axxxx",
79
+ "User-Agent": "Mozilla/5.0xxxx",
80
+ "sec-ch-ua-mobile": "?0",
81
+ "sec-fetch-user": "?1",
82
+ "referer": "https://www.yourwebsite.com",
83
+ "Sec-Fetch-Dest": "document",
84
+ "Sec-Fetch-Mode": "navigate",
85
+ "Sec-Fetch-Site": "same-origin",
86
+ "accept-language": "en",
87
+ },
88
+ "page_url": "https://www.yourwebsite.com",
89
+ "proxy": "your proxyxxxx",
90
+ "token": "_VPCTZXP5bhinxxxx"
91
+ }
92
+ }
93
+
58
94
  Notes:
59
95
  https://docs.capsolver.com/en/guide/captcha/FriendlyCaptcha/
60
96
  """
@@ -1,4 +1,4 @@
1
- from typing import Dict
1
+ from typing import Any, Dict
2
2
 
3
3
  from .core.base import CaptchaParams
4
4
  from .core.enum import CaptchaTypeEnm
@@ -88,7 +88,7 @@ class ImageToText(CaptchaParams):
88
88
 
89
89
  super().__init__(api_key=api_key, captcha_type=CaptchaTypeEnm.ImageToTextTask, **kwargs)
90
90
 
91
- def captcha_handler(self, task_payload: Dict) -> Dict[str, str]:
91
+ def captcha_handler(self, task_payload: Dict) -> Dict[str, Any]:
92
92
  """
93
93
  Synchronous method for captcha solving
94
94
 
@@ -104,7 +104,7 @@ class ImageToText(CaptchaParams):
104
104
  task_payload.pop("type", None)
105
105
  return super().captcha_handler(task_payload=task_payload)
106
106
 
107
- async def aio_captcha_handler(self, task_payload: Dict) -> Dict[str, str]:
107
+ async def aio_captcha_handler(self, task_payload: Dict) -> Dict[str, Any]:
108
108
  """
109
109
  Asynchronous method for captcha solving
110
110
 
@@ -38,6 +38,23 @@ class MtCaptcha(CaptchaParams):
38
38
  }
39
39
  }
40
40
 
41
+ >>> import asyncio
42
+ >>> from python3_capsolver.mt_captcha import MtCaptcha
43
+ >>> from python3_capsolver.core.enum import CaptchaTypeEnm
44
+ >>> asyncio.run(MtCaptcha(api_key="CAI-12345....",
45
+ ... captcha_type=CaptchaTypeEnm.MtCaptchaTaskProxyLess)
46
+ ... .aio_captcha_handler(task_payload={"websiteURL": "some-url"}))
47
+ {
48
+ "errorId":0,
49
+ "errorCode":"None",
50
+ "errorDescription":"None",
51
+ "taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
52
+ "status":"ready",
53
+ "solution":{
54
+ "token": ""
55
+ }
56
+ }
57
+
41
58
  Notes:
42
59
  https://docs.capsolver.com/en/guide/captcha/MtCaptcha/
43
60
  """
@@ -1,4 +1,4 @@
1
- from typing import Dict
1
+ from typing import Any, Dict
2
2
 
3
3
  from .core.base import CaptchaParams
4
4
  from .core.enum import CaptchaTypeEnm
@@ -69,7 +69,7 @@ class VisionEngine(CaptchaParams):
69
69
  def __init__(self, api_key: str, **kwargs):
70
70
  super().__init__(api_key=api_key, captcha_type=CaptchaTypeEnm.VisionEngine, **kwargs)
71
71
 
72
- def captcha_handler(self, task_payload: Dict) -> Dict[str, str]:
72
+ def captcha_handler(self, task_payload: Dict) -> Dict[str, Any]:
73
73
  """
74
74
  Synchronous method for captcha solving
75
75
 
@@ -85,7 +85,7 @@ class VisionEngine(CaptchaParams):
85
85
  task_payload.pop("type", None)
86
86
  return super().captcha_handler(task_payload=task_payload)
87
87
 
88
- async def aio_captcha_handler(self, task_payload: Dict) -> Dict[str, str]:
88
+ async def aio_captcha_handler(self, task_payload: Dict) -> Dict[str, Any]:
89
89
  """
90
90
  Asynchronous method for captcha solving
91
91
 
@@ -12,7 +12,7 @@ class YandexCaptcha(CaptchaParams):
12
12
 
13
13
  Args:
14
14
  api_key: Capsolver API key
15
- captcha_type: Captcha type name, like ``FriendlyCaptchaTaskProxyless`` and etc.
15
+ captcha_type: Captcha type name, like ``YandexCaptchaTaskProxyLess`` and etc.
16
16
  kwargs: additional params for client, like captcha waiting time
17
17
  available keys:
18
18
  - sleep_time: int - captcha solution waintig time in sec
@@ -39,14 +39,34 @@ class YandexCaptcha(CaptchaParams):
39
39
  }
40
40
  }
41
41
 
42
+ >>> import asyncio
43
+ >>> from python3_capsolver.core.enum import CaptchaTypeEnm
44
+ >>> from python3_capsolver.yandex import YandexCaptcha
45
+ >>> asyncio.run(YandexCaptcha(api_key="CAP-XXXXX",
46
+ ... captcha_type=CaptchaTypeEnm.YandexCaptchaTaskProxyLess,
47
+ ... ).aio_captcha_handler(task_payload={
48
+ ... "websiteURL": "https://www.yourwebsite.com",
49
+ ... "websiteKey": "ysc1_bFdbbET5WBnPTvoE5jTXxxxx"
50
+ ... }))
51
+ {
52
+ "errorId":0,
53
+ "errorCode":"None",
54
+ "errorDescription":"None",
55
+ "taskId":"db0a3153-621d-4f5e-8554-a1c032597ee7",
56
+ "status":"ready",
57
+ "solution":{
58
+ "token": "dD0xNzMzMjc0MjkzO2k9Nxxxx"
59
+ }
60
+ }
61
+
42
62
  Notes:
43
- https://docs.capsolver.com/en/guide/captcha/FriendlyCaptcha/
63
+ https://docs.capsolver.com/en/guide/captcha/YandexCaptcha/
44
64
  """
45
65
 
46
66
  def __init__(
47
67
  self,
48
68
  api_key: str,
49
- captcha_type: Union[CaptchaTypeEnm, str] = CaptchaTypeEnm.FriendlyCaptchaTaskProxyless,
69
+ captcha_type: Union[CaptchaTypeEnm, str] = CaptchaTypeEnm.YandexCaptchaTaskProxyLess,
50
70
  **kwargs,
51
71
  ):
52
72
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: python3-capsolver
3
- Version: 1.0.0a0
3
+ Version: 1.0.1
4
4
  Summary: Python 3.8+ Capsolver library with AIO module.
5
5
  Author-email: AndreiDrang <python-captcha@pm.me>
6
6
  License: MIT License
@@ -44,6 +44,7 @@ Requires-Dist: tenacity<10,>=8
44
44
  [![Downloads](https://static.pepy.tech/badge/python3-capsolver/month)](https://pepy.tech/project/python3-capsolver)
45
45
  [![Static Badge](https://img.shields.io/badge/docs-Sphinx-green?label=Documentation&labelColor=gray)](https://andreidrang.github.io/python3-capsolver/)
46
46
 
47
+ [![Maintainability](https://api.codeclimate.com/v1/badges/3c30167b5fb37a0775ea/maintainability)](https://codeclimate.com/github/AndreiDrang/python3-capsolver/maintainability)
47
48
  [![Codacy Badge](https://app.codacy.com/project/badge/Grade/323d4eda0fe1477bbea8fe8902b9e97e)](https://www.codacy.com/gh/AndreiDrang/python3-capsolver/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=AndreiDrang/python3-capsolver&amp;utm_campaign=Badge_Grade)
48
49
  [![codecov](https://codecov.io/gh/AndreiDrang/python3-capsolver/branch/main/graph/badge.svg?token=2L4VVIF4G8)](https://codecov.io/gh/AndreiDrang/python3-capsolver)
49
50
 
@@ -31,10 +31,15 @@ src/python3_capsolver/core/serializer.py
31
31
  src/python3_capsolver/core/sio_captcha_instrument.py
32
32
  src/python3_capsolver/core/utils.py
33
33
  tests/test_aws_waf.py
34
+ tests/test_cloudflare.py
34
35
  tests/test_control.py
35
36
  tests/test_core.py
37
+ tests/test_datadome.py
38
+ tests/test_friendly.py
36
39
  tests/test_gee_test.py
37
40
  tests/test_image_to_text.py
38
41
  tests/test_instrument.py
39
42
  tests/test_mt_captcha.py
40
- tests/test_recaptcha.py
43
+ tests/test_recaptcha.py
44
+ tests/test_vision_engine.py
45
+ tests/test_yandex.py
@@ -0,0 +1,115 @@
1
+ import pytest
2
+
3
+ from tests.conftest import BaseTest
4
+ from python3_capsolver.aws_waf import AwsWaf
5
+ from python3_capsolver.core.enum import CaptchaTypeEnm, ResponseStatusEnm
6
+
7
+
8
+ class TestAwsWafBase(BaseTest):
9
+ captcha_types = (
10
+ CaptchaTypeEnm.AwsWafClassification,
11
+ CaptchaTypeEnm.AntiAwsWafTask,
12
+ CaptchaTypeEnm.AntiAwsWafTaskProxyLess,
13
+ )
14
+
15
+ @pytest.mark.parametrize("captcha_type", captcha_types)
16
+ def test_captcha_handler_exist(self, captcha_type):
17
+ instance = AwsWaf(api_key=self.get_random_string(36), captcha_type=captcha_type)
18
+ assert "captcha_handler" in instance.__dir__()
19
+ assert "aio_captcha_handler" in instance.__dir__()
20
+
21
+ @pytest.mark.parametrize("captcha_type", captcha_types)
22
+ def test_api_key_err(self, captcha_type):
23
+ result = AwsWaf(api_key=self.get_random_string(36), captcha_type=captcha_type).captcha_handler(
24
+ task_payload={"some": "data"}
25
+ )
26
+ assert result["errorId"] == 1
27
+ assert result["errorCode"] in ("ERROR_INVALID_TASK_DATA", "ERROR_KEY_DENIED_ACCESS")
28
+ assert result["solution"] is None
29
+
30
+ @pytest.mark.parametrize("captcha_type", captcha_types)
31
+ async def test_aio_api_key_err(self, captcha_type):
32
+ result = await AwsWaf(api_key=self.get_random_string(36), captcha_type=captcha_type).aio_captcha_handler(
33
+ task_payload={"some": "data"}
34
+ )
35
+ assert result["errorId"] == 1
36
+ assert result["errorCode"] in ("ERROR_INVALID_TASK_DATA", "ERROR_KEY_DENIED_ACCESS")
37
+ assert result["solution"] is None
38
+
39
+
40
+ class TestAwsWafClassification(BaseTest):
41
+ toycarcity_image = "tests/files/aws_waf_class_toycarcity.png"
42
+
43
+ def test_success(self):
44
+ result = AwsWaf(api_key=self.API_KEY, captcha_type=CaptchaTypeEnm.AwsWafClassification).captcha_handler(
45
+ task_payload={
46
+ "images": [self.read_image_as_str(file_path=self.toycarcity_image)],
47
+ "question": "aws:toycarcity:carcity",
48
+ }
49
+ )
50
+ assert result["errorId"] == 0
51
+ assert result["errorCode"] is None
52
+ assert isinstance(result["solution"], dict)
53
+ assert result["status"] == ResponseStatusEnm.Ready.value
54
+ assert result["taskId"] is not ""
55
+
56
+ def test_api_key_err(self):
57
+ result = AwsWaf(
58
+ api_key=self.get_random_string(36), captcha_type=CaptchaTypeEnm.AwsWafClassification
59
+ ).captcha_handler(
60
+ task_payload={
61
+ "images": [self.read_image_as_str()],
62
+ "question": "aws:toycarcity:carcity",
63
+ }
64
+ )
65
+ assert result["errorId"] == 1
66
+ assert result["errorCode"] == "ERROR_KEY_DENIED_ACCESS"
67
+ assert result["solution"] is None
68
+
69
+ async def test_aio_api_key_err(self):
70
+ result = await AwsWaf(
71
+ api_key=self.get_random_string(36), captcha_type=CaptchaTypeEnm.AwsWafClassification
72
+ ).aio_captcha_handler(
73
+ task_payload={
74
+ "images": [self.read_image_as_str()],
75
+ "question": "aws:toycarcity:carcity",
76
+ }
77
+ )
78
+ assert result["errorId"] == 1
79
+ assert result["errorCode"] == "ERROR_KEY_DENIED_ACCESS"
80
+ assert result["solution"] is None
81
+
82
+
83
+ class TestAntiAwsWafTaskProxyLess(BaseTest):
84
+
85
+ def test_api_key_err(self):
86
+ result = AwsWaf(
87
+ api_key=self.get_random_string(36), captcha_type=CaptchaTypeEnm.AntiAwsWafTaskProxyLess
88
+ ).captcha_handler(
89
+ task_payload={
90
+ "websiteURL": "https://efw47fpad9.execute-api.us-east-1.amazonaws.com/latest",
91
+ "awsKey": "AQIDAHjcYu/GjX+QlghicBg......shMIKvZswZemrVVqA==",
92
+ "awsIv": "CgAAFDIlckAAAAid",
93
+ "awsContext": "7DhQfG5CmoY90ZdxdHCi8WtJ3z......njNKULdcUUVEtxTk=",
94
+ "awsChallengeJS": "https://41bcdd4fb3cb.610cd090.us-east-1.token.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/challenge.js",
95
+ }
96
+ )
97
+ assert result["errorId"] == 1
98
+ assert result["errorCode"] == "ERROR_KEY_DENIED_ACCESS"
99
+ assert result["solution"] is None
100
+
101
+ async def test_aio_api_key_err(self):
102
+ result = await AwsWaf(
103
+ api_key=self.get_random_string(36), captcha_type=CaptchaTypeEnm.AntiAwsWafTaskProxyLess
104
+ ).aio_captcha_handler(
105
+ task_payload={
106
+ "websiteURL": "https://efw47fpad9.execute-api.us-east-1.amazonaws.com/latest",
107
+ "awsKey": "AQIDAHjcYu/GjX+QlghicBg......shMIKvZswZemrVVqA==",
108
+ "awsIv": "CgAAFDIlckAAAAid",
109
+ "awsContext": "7DhQfG5CmoY90ZdxdHCi8WtJ3z......njNKULdcUUVEtxTk=",
110
+ "awsChallengeJS": "https://41bcdd4fb3cb.610cd090.us-east-1.token.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/challenge.js",
111
+ }
112
+ )
113
+ assert result["errorId"] == 1
114
+ assert result["errorCode"] == "ERROR_KEY_DENIED_ACCESS"
115
+ assert result["solution"] is None
@@ -1,26 +1,25 @@
1
1
  import pytest
2
2
 
3
3
  from tests.conftest import BaseTest
4
- from python3_capsolver.aws_waf import AwsWaf
5
4
  from python3_capsolver.core.enum import CaptchaTypeEnm
5
+ from python3_capsolver.cloudflare import Cloudflare
6
6
 
7
7
 
8
- class TestAwsWafBase(BaseTest):
8
+ class TestCloudflare(BaseTest):
9
9
  captcha_types = (
10
- CaptchaTypeEnm.AwsWafClassification,
11
- CaptchaTypeEnm.AntiAwsWafTask,
12
- CaptchaTypeEnm.AntiAwsWafTaskProxyLess,
10
+ CaptchaTypeEnm.AntiCloudflareTask,
11
+ CaptchaTypeEnm.AntiTurnstileTaskProxyLess,
13
12
  )
14
13
 
15
14
  @pytest.mark.parametrize("captcha_type", captcha_types)
16
15
  def test_captcha_handler_exist(self, captcha_type):
17
- instance = AwsWaf(api_key=self.get_random_string(36), captcha_type=captcha_type)
16
+ instance = Cloudflare(api_key=self.get_random_string(36), captcha_type=captcha_type)
18
17
  assert "captcha_handler" in instance.__dir__()
19
18
  assert "aio_captcha_handler" in instance.__dir__()
20
19
 
21
20
  @pytest.mark.parametrize("captcha_type", captcha_types)
22
21
  def test_api_key_err(self, captcha_type):
23
- result = AwsWaf(api_key=self.get_random_string(36), captcha_type=captcha_type).captcha_handler(
22
+ result = Cloudflare(api_key=self.get_random_string(36), captcha_type=captcha_type).captcha_handler(
24
23
  task_payload={"some": "data"}
25
24
  )
26
25
  assert result["errorId"] == 1
@@ -29,7 +28,7 @@ class TestAwsWafBase(BaseTest):
29
28
 
30
29
  @pytest.mark.parametrize("captcha_type", captcha_types)
31
30
  async def test_aio_api_key_err(self, captcha_type):
32
- result = await AwsWaf(api_key=self.get_random_string(36), captcha_type=captcha_type).aio_captcha_handler(
31
+ result = await Cloudflare(api_key=self.get_random_string(36), captcha_type=captcha_type).aio_captcha_handler(
33
32
  task_payload={"some": "data"}
34
33
  )
35
34
  assert result["errorId"] == 1
@@ -23,7 +23,7 @@ class TestCore(BaseTest):
23
23
  def test_create_base(self):
24
24
  CaptchaParams(
25
25
  api_key=self.get_random_string(36),
26
- captcha_type=CaptchaTypeEnm.VisionEngine,
26
+ captcha_type=CaptchaTypeEnm.Control,
27
27
  request_url=REQUEST_URL,
28
28
  sleep_time=self.sleep_time,
29
29
  )
@@ -31,7 +31,7 @@ class TestCore(BaseTest):
31
31
  def test_aio_create_base(self):
32
32
  CaptchaParams(
33
33
  api_key=self.get_random_string(36),
34
- captcha_type=CaptchaTypeEnm.VisionEngine,
34
+ captcha_type=CaptchaTypeEnm.Control,
35
35
  request_url=REQUEST_URL,
36
36
  sleep_time=self.sleep_time,
37
37
  )
@@ -39,7 +39,7 @@ class TestCore(BaseTest):
39
39
  def test_create_base_context(self):
40
40
  with CaptchaParams(
41
41
  api_key=self.get_random_string(36),
42
- captcha_type=CaptchaTypeEnm.VisionEngine,
42
+ captcha_type=CaptchaTypeEnm.Control,
43
43
  request_url=REQUEST_URL,
44
44
  sleep_time=self.sleep_time,
45
45
  ) as instance:
@@ -48,7 +48,7 @@ class TestCore(BaseTest):
48
48
  async def test_aio_create_base_context(self):
49
49
  async with CaptchaParams(
50
50
  api_key=self.get_random_string(36),
51
- captcha_type=CaptchaTypeEnm.VisionEngine,
51
+ captcha_type=CaptchaTypeEnm.Control,
52
52
  request_url=REQUEST_URL,
53
53
  sleep_time=self.sleep_time,
54
54
  ) as instance:
@@ -60,19 +60,19 @@ class TestCore(BaseTest):
60
60
 
61
61
  def test_no_key_err(self):
62
62
  with pytest.raises(TypeError):
63
- CaptchaParams(captcha_type=CaptchaTypeEnm.VisionEngine, request_url=REQUEST_URL, sleep_time=self.sleep_time)
63
+ CaptchaParams(captcha_type=CaptchaTypeEnm.Control, request_url=REQUEST_URL, sleep_time=self.sleep_time)
64
64
 
65
65
  def test_no_key_err_context(self):
66
66
  with pytest.raises(TypeError):
67
67
  with CaptchaParams(
68
- captcha_type=CaptchaTypeEnm.VisionEngine, request_url=REQUEST_URL, sleep_time=self.sleep_time
68
+ captcha_type=CaptchaTypeEnm.Control, request_url=REQUEST_URL, sleep_time=self.sleep_time
69
69
  ) as instance:
70
70
  pass
71
71
 
72
72
  async def test_aio_no_key_err_context(self):
73
73
  with pytest.raises(TypeError):
74
74
  async with CaptchaParams(
75
- captcha_type=CaptchaTypeEnm.VisionEngine, request_url=REQUEST_URL, sleep_time=self.sleep_time
75
+ captcha_type=CaptchaTypeEnm.Control, request_url=REQUEST_URL, sleep_time=self.sleep_time
76
76
  ) as instance:
77
77
  pass
78
78
 
@@ -80,7 +80,7 @@ class TestCore(BaseTest):
80
80
  with pytest.raises(Exception):
81
81
  with CaptchaParams(
82
82
  api_key=self.get_random_string(36),
83
- captcha_type=CaptchaTypeEnm.VisionEngine,
83
+ captcha_type=CaptchaTypeEnm.Control,
84
84
  request_url=REQUEST_URL,
85
85
  sleep_time=self.sleep_time,
86
86
  ) as instance:
@@ -90,14 +90,14 @@ class TestCore(BaseTest):
90
90
  with pytest.raises(Exception):
91
91
  async with CaptchaParams(
92
92
  api_key=self.get_random_string(36),
93
- captcha_type=CaptchaTypeEnm.VisionEngine,
93
+ captcha_type=CaptchaTypeEnm.Control,
94
94
  request_url=REQUEST_URL,
95
95
  sleep_time=self.sleep_time,
96
96
  ) as instance:
97
97
  raise Exception()
98
98
 
99
99
 
100
- class TestEnum(BaseTest):
100
+ class TestMyEnum(BaseTest):
101
101
  def test_enum_list(self):
102
102
  assert isinstance(MyEnum.list(), list)
103
103
 
@@ -0,0 +1,33 @@
1
+ import pytest
2
+
3
+ from tests.conftest import BaseTest
4
+ from python3_capsolver.core.enum import CaptchaTypeEnm
5
+ from python3_capsolver.datadome_slider import DatadomeSlider
6
+
7
+
8
+ class TestDatadomeSliderBase(BaseTest):
9
+ captcha_types = (CaptchaTypeEnm.DatadomeSliderTask,)
10
+
11
+ @pytest.mark.parametrize("captcha_type", captcha_types)
12
+ def test_captcha_handler_exist(self, captcha_type):
13
+ instance = DatadomeSlider(api_key=self.get_random_string(36), captcha_type=captcha_type)
14
+ assert "captcha_handler" in instance.__dir__()
15
+ assert "aio_captcha_handler" in instance.__dir__()
16
+
17
+ @pytest.mark.parametrize("captcha_type", captcha_types)
18
+ def test_api_key_err(self, captcha_type):
19
+ result = DatadomeSlider(api_key=self.get_random_string(36), captcha_type=captcha_type).captcha_handler(
20
+ task_payload={"some": "data"}
21
+ )
22
+ assert result["errorId"] == 1
23
+ assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA")
24
+ assert result["solution"] is None
25
+
26
+ @pytest.mark.parametrize("captcha_type", captcha_types)
27
+ async def test_aio_api_key_err(self, captcha_type):
28
+ result = await DatadomeSlider(
29
+ api_key=self.get_random_string(36), captcha_type=captcha_type
30
+ ).aio_captcha_handler(task_payload={"some": "data"})
31
+ assert result["errorId"] == 1
32
+ assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA")
33
+ assert result["solution"] is None
@@ -0,0 +1,33 @@
1
+ import pytest
2
+
3
+ from tests.conftest import BaseTest
4
+ from python3_capsolver.core.enum import CaptchaTypeEnm
5
+ from python3_capsolver.friendly_captcha import FriendlyCaptcha
6
+
7
+
8
+ class TestFriendlyCaptchaBase(BaseTest):
9
+ captcha_types = (CaptchaTypeEnm.FriendlyCaptchaTaskProxyless,)
10
+
11
+ @pytest.mark.parametrize("captcha_type", captcha_types)
12
+ def test_captcha_handler_exist(self, captcha_type):
13
+ instance = FriendlyCaptcha(api_key=self.get_random_string(36), captcha_type=captcha_type)
14
+ assert "captcha_handler" in instance.__dir__()
15
+ assert "aio_captcha_handler" in instance.__dir__()
16
+
17
+ @pytest.mark.parametrize("captcha_type", captcha_types)
18
+ def test_api_key_err(self, captcha_type):
19
+ result = FriendlyCaptcha(api_key=self.get_random_string(36), captcha_type=captcha_type).captcha_handler(
20
+ task_payload={"some": "data"}
21
+ )
22
+ assert result["errorId"] == 1
23
+ assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA")
24
+ assert result["solution"] is None
25
+
26
+ @pytest.mark.parametrize("captcha_type", captcha_types)
27
+ async def test_aio_api_key_err(self, captcha_type):
28
+ result = await FriendlyCaptcha(
29
+ api_key=self.get_random_string(36), captcha_type=captcha_type
30
+ ).aio_captcha_handler(task_payload={"some": "data"})
31
+ assert result["errorId"] == 1
32
+ assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA")
33
+ assert result["solution"] is None
@@ -0,0 +1,23 @@
1
+ from tests.conftest import BaseTest
2
+ from python3_capsolver.vision_engine import VisionEngine
3
+
4
+
5
+ class TestVisionEngineBase(BaseTest):
6
+ def test_captcha_handler_exist(self):
7
+ instance = VisionEngine(api_key=self.get_random_string(36))
8
+ assert "captcha_handler" in instance.__dir__()
9
+ assert "aio_captcha_handler" in instance.__dir__()
10
+
11
+ def test_api_key_err(self):
12
+ result = VisionEngine(api_key=self.get_random_string(36)).captcha_handler(task_payload={"some": "data"})
13
+ assert result["errorId"] == 1
14
+ assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA")
15
+ assert result["solution"] is None
16
+
17
+ async def test_aio_api_key_err(self):
18
+ result = await VisionEngine(api_key=self.get_random_string(36)).aio_captcha_handler(
19
+ task_payload={"some": "data"}
20
+ )
21
+ assert result["errorId"] == 1
22
+ assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA")
23
+ assert result["solution"] is None
@@ -0,0 +1,33 @@
1
+ import pytest
2
+
3
+ from tests.conftest import BaseTest
4
+ from python3_capsolver.yandex import YandexCaptcha
5
+ from python3_capsolver.core.enum import CaptchaTypeEnm
6
+
7
+
8
+ class TestYandexCaptchaBase(BaseTest):
9
+ captcha_types = (CaptchaTypeEnm.YandexCaptchaTaskProxyLess,)
10
+
11
+ @pytest.mark.parametrize("captcha_type", captcha_types)
12
+ def test_captcha_handler_exist(self, captcha_type):
13
+ instance = YandexCaptcha(api_key=self.get_random_string(36), captcha_type=captcha_type)
14
+ assert "captcha_handler" in instance.__dir__()
15
+ assert "aio_captcha_handler" in instance.__dir__()
16
+
17
+ @pytest.mark.parametrize("captcha_type", captcha_types)
18
+ def test_api_key_err(self, captcha_type):
19
+ result = YandexCaptcha(api_key=self.get_random_string(36), captcha_type=captcha_type).captcha_handler(
20
+ task_payload={"some": "data"}
21
+ )
22
+ assert result["errorId"] == 1
23
+ assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA")
24
+ assert result["solution"] is None
25
+
26
+ @pytest.mark.parametrize("captcha_type", captcha_types)
27
+ async def test_aio_api_key_err(self, captcha_type):
28
+ result = await YandexCaptcha(api_key=self.get_random_string(36), captcha_type=captcha_type).aio_captcha_handler(
29
+ task_payload={"some": "data"}
30
+ )
31
+ assert result["errorId"] == 1
32
+ assert result["errorCode"] in ("ERROR_KEY_DENIED_ACCESS", "ERROR_INVALID_TASK_DATA")
33
+ assert result["solution"] is None
@@ -1 +0,0 @@
1
- __version__ = "1.0.0a"