capmonster-python 2.5.0__tar.gz → 2.6.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 (23) hide show
  1. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/PKG-INFO +8 -4
  2. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/README.md +7 -3
  3. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/__init__.py +1 -0
  4. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/capmonster.py +57 -6
  5. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/compleximage.py +6 -5
  6. capmonster_python-2.6.1/capmonster_python/datadome.py +19 -0
  7. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/recaptcha_v2_enterprise.py +3 -2
  8. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/utils.py +3 -1
  9. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python.egg-info/PKG-INFO +8 -4
  10. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python.egg-info/SOURCES.txt +1 -0
  11. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/setup.py +2 -2
  12. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/LICENSE +0 -0
  13. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/fun_captcha.py +0 -0
  14. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/geetest.py +0 -0
  15. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/hcaptcha.py +0 -0
  16. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/image_to_text.py +0 -0
  17. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/recaptcha_v2.py +0 -0
  18. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/recaptcha_v3.py +0 -0
  19. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python/turnstile.py +0 -0
  20. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python.egg-info/dependency_links.txt +0 -0
  21. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python.egg-info/requires.txt +0 -0
  22. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/capmonster_python.egg-info/top_level.txt +0 -0
  23. {capmonster_python-2.5.0 → capmonster_python-2.6.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: capmonster_python
3
- Version: 2.5.0
3
+ Version: 2.6.1
4
4
  Summary: capmonster.cloud library for Python
5
5
  Home-page: https://github.com/alperensert/capmonster_python
6
6
  Author: Alperen Sert
@@ -29,20 +29,23 @@ Requires-Dist: six
29
29
 
30
30
  Capmonster.cloud for Python
31
31
  =
32
- ![PyPI - Wheel](https://img.shields.io/pypi/wheel/capmonster-python?style=plastic) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/capmonster_python?style=flat) ![GitHub last commit](https://img.shields.io/github/last-commit/alperensert/capmonster_python?style=flat) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/alperensert/capmonster_python?style=flat) ![PyPI - Downloads](https://img.shields.io/pypi/dm/capmonster_python?style=flat) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/alperensert/capmonster_python?style=flat) ![GitHub Repo stars](https://img.shields.io/github/stars/alperensert/capmonster_python?style=social)
32
+ ![PyPI - Wheel](https://img.shields.io/pypi/wheel/capmonster-python?style=plastic) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/capmonster_python?style=flat) ![GitHub last commit](https://img.shields.io/github/last-commit/alperensert/capmonster_python?style=flat) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/alperensert/capmonster_python?style=flat) ![PyPI - Downloads](https://img.shields.io/pypi/dm/capmonster_python?style=flat) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/alperensert/capmonster_python?style=flat) ![GitHub Repo stars](https://img.shields.io/github/stars/alperensert/capmonster_python?style=social)
33
33
 
34
34
  [Capmonster.cloud](https://capmonster.cloud) package for Python3
35
35
 
36
- If you have any problem with usage, [read the documentation](https://alperensert.github.io/capmonster_python) or [create an issue](https://github.com/alperensert/capmonster_python/issues/new)
36
+ If you have any problem with usage, [read the documentation](https://alperensert.github.io/capmonster_python)
37
+ or [create an issue](https://github.com/alperensert/capmonster_python/issues/new)
37
38
 
38
39
  *At least 2x cheaper, up to 30x faster than manual recognition services.*
39
40
 
40
41
  ### Installation
42
+
41
43
  ```
42
44
  pip install capmonster_python
43
45
  ```
44
46
 
45
47
  ### Supported captcha types
48
+
46
49
  - Image to text
47
50
  - Recaptcha v2
48
51
  - Recaptcha v2 Enterprise
@@ -51,6 +54,7 @@ pip install capmonster_python
51
54
  - HCaptcha
52
55
  - GeeTest
53
56
  - Turnstile Task
57
+ - Data Dome
54
58
 
55
59
  Usage examples
56
60
  -
@@ -95,7 +99,7 @@ from capmonster_python import GeeTestTask
95
99
 
96
100
  capmonster = GeeTestTask("API_KEY")
97
101
  task_id = capmonster.create_task("website_url", "gt", "challenge")
98
- result= capmonster.join_task_result(task_id)
102
+ result = capmonster.join_task_result(task_id)
99
103
  print(result.get("challenge"))
100
104
  print(result.get("seccode"))
101
105
  print(result.get("validate"))
@@ -1,19 +1,22 @@
1
1
  Capmonster.cloud for Python
2
2
  =
3
- ![PyPI - Wheel](https://img.shields.io/pypi/wheel/capmonster-python?style=plastic) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/capmonster_python?style=flat) ![GitHub last commit](https://img.shields.io/github/last-commit/alperensert/capmonster_python?style=flat) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/alperensert/capmonster_python?style=flat) ![PyPI - Downloads](https://img.shields.io/pypi/dm/capmonster_python?style=flat) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/alperensert/capmonster_python?style=flat) ![GitHub Repo stars](https://img.shields.io/github/stars/alperensert/capmonster_python?style=social)
3
+ ![PyPI - Wheel](https://img.shields.io/pypi/wheel/capmonster-python?style=plastic) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/capmonster_python?style=flat) ![GitHub last commit](https://img.shields.io/github/last-commit/alperensert/capmonster_python?style=flat) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/alperensert/capmonster_python?style=flat) ![PyPI - Downloads](https://img.shields.io/pypi/dm/capmonster_python?style=flat) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/alperensert/capmonster_python?style=flat) ![GitHub Repo stars](https://img.shields.io/github/stars/alperensert/capmonster_python?style=social)
4
4
 
5
5
  [Capmonster.cloud](https://capmonster.cloud) package for Python3
6
6
 
7
- If you have any problem with usage, [read the documentation](https://alperensert.github.io/capmonster_python) or [create an issue](https://github.com/alperensert/capmonster_python/issues/new)
7
+ If you have any problem with usage, [read the documentation](https://alperensert.github.io/capmonster_python)
8
+ or [create an issue](https://github.com/alperensert/capmonster_python/issues/new)
8
9
 
9
10
  *At least 2x cheaper, up to 30x faster than manual recognition services.*
10
11
 
11
12
  ### Installation
13
+
12
14
  ```
13
15
  pip install capmonster_python
14
16
  ```
15
17
 
16
18
  ### Supported captcha types
19
+
17
20
  - Image to text
18
21
  - Recaptcha v2
19
22
  - Recaptcha v2 Enterprise
@@ -22,6 +25,7 @@ pip install capmonster_python
22
25
  - HCaptcha
23
26
  - GeeTest
24
27
  - Turnstile Task
28
+ - Data Dome
25
29
 
26
30
  Usage examples
27
31
  -
@@ -66,7 +70,7 @@ from capmonster_python import GeeTestTask
66
70
 
67
71
  capmonster = GeeTestTask("API_KEY")
68
72
  task_id = capmonster.create_task("website_url", "gt", "challenge")
69
- result= capmonster.join_task_result(task_id)
73
+ result = capmonster.join_task_result(task_id)
70
74
  print(result.get("challenge"))
71
75
  print(result.get("seccode"))
72
76
  print(result.get("validate"))
@@ -7,3 +7,4 @@ from .image_to_text import ImageToTextTask
7
7
  from .geetest import GeeTestTask
8
8
  from .utils import CapmonsterException
9
9
  from .compleximage import ComplexImageTask
10
+ from .datadome import DataDomeTask
@@ -5,6 +5,7 @@ from .utils import *
5
5
 
6
6
 
7
7
  class Capmonster:
8
+ """A class that interacts with the Capmonster API."""
8
9
  __SOFT_ID = 30
9
10
  _HOST_URL = "https://api.capmonster.cloud"
10
11
  _CREATE_TASK_URL = "/createTask"
@@ -16,11 +17,20 @@ class Capmonster:
16
17
  def __init__(self, client_key):
17
18
  self._client_key = client_key
18
19
 
19
- def get_balance(self):
20
+ def get_balance(self) -> float:
21
+ """
22
+ Retrieves the balance of the client.
23
+
24
+ :return: The balance of the client as a float.
25
+ """
20
26
  data = {"clientKey": self._client_key}
21
27
  return self._make_request("getBalance", data).get("balance")
22
28
 
23
29
  def get_task_result(self, task_id: int):
30
+ """
31
+ :param task_id: The ID of the task for which the result is requested.
32
+ :return: The result of the task if it is ready, otherwise False.
33
+ """
24
34
  data = {
25
35
  "clientKey": self._client_key,
26
36
  "taskId": task_id
@@ -55,7 +65,15 @@ class Capmonster:
55
65
  61, "ERROR_MAXIMUM_TIME_EXCEED", "Maximum time is exceed.")
56
66
 
57
67
  def report_incorrect_captcha(self, captcha_type: str, task_id: int) -> bool:
58
- if captcha_type is not "image" or "token":
68
+ """
69
+ Reports an incorrect captcha.
70
+
71
+ :param captcha_type: The type of captcha ("image" or "token").
72
+ :param task_id: The ID of the task.
73
+ :return: True if the captcha is successfully reported, False otherwise.
74
+ :raises CapmonsterException: If the captcha type is invalid.
75
+ """
76
+ if captcha_type != "image" or "token":
59
77
  raise CapmonsterException(
60
78
  1, "ERROR_INCORRECT_CAPTCHA_TYPE", "Valid captcha_type parameters are only 'image' or 'token'.")
61
79
  try:
@@ -71,7 +89,7 @@ class Capmonster:
71
89
  "clientKey": self._client_key,
72
90
  "taskId": task_id
73
91
  }
74
- if captcha_type is "image":
92
+ if captcha_type == "image":
75
93
  response = self._make_request("reportIncorrectImageCaptcha", data)
76
94
  else:
77
95
  response = self._make_request("reportIncorrectTokenCaptcha", data)
@@ -111,13 +129,13 @@ class Capmonster:
111
129
  if cookies is None:
112
130
  return data
113
131
  str_cookies = ""
114
- if type(cookies) == dict:
132
+ if type(cookies) is dict:
115
133
  for key, value in cookies.items():
116
134
  if value == list(cookies.items())[-1][1]:
117
135
  str_cookies += "{}={}".format(key, value)
118
136
  else:
119
137
  str_cookies += "{}={};".format(key, value)
120
- elif type(cookies) == list:
138
+ elif type(cookies) is list:
121
139
  for i in cookies:
122
140
  if not len(cookies) % 2 == 0:
123
141
  raise AttributeError(
@@ -128,7 +146,7 @@ class Capmonster:
128
146
  str_cookies += "{}".format(i)
129
147
  elif cookies.index(i) % 2 == 1:
130
148
  str_cookies += "{};".format(i)
131
- elif type(cookies) == str:
149
+ elif type(cookies) is str:
132
150
  data["task"]["cookies"] = cookies
133
151
  return data
134
152
  data["task"]["cookies"] = str_cookies
@@ -146,6 +164,16 @@ class Proxy(Capmonster):
146
164
 
147
165
  def set_proxy(self, proxy_type: str, proxy_address: str, proxy_port: int,
148
166
  proxy_login: str = None, proxy_password: str = None):
167
+ """
168
+ Sets the proxy settings for the client.
169
+
170
+ :param proxy_type: The type of the proxy. (e.g. "HTTP", "SOCKS5")
171
+ :param proxy_address: The address of the proxy server.
172
+ :param proxy_port: The port number of the proxy server.
173
+ :param proxy_login: (optional) The login username for proxy authentication.
174
+ :param proxy_password: (optional) The login password for proxy authentication.
175
+ :return: None
176
+ """
149
177
  self._proxy_type = proxy_type
150
178
  self._proxy_address = proxy_address
151
179
  self._proxy_port = proxy_port
@@ -153,6 +181,11 @@ class Proxy(Capmonster):
153
181
  self._proxy_password = proxy_password
154
182
 
155
183
  def disable_proxy(self):
184
+ """
185
+ Disables the proxy settings.
186
+
187
+ :return: None
188
+ """
156
189
  self._proxy_type = None
157
190
  self._proxy_address = None
158
191
  self._proxy_port = None
@@ -184,9 +217,20 @@ class UserAgent(Capmonster):
184
217
  self._fallback = False
185
218
 
186
219
  def set_user_agent(self, user_agent: str):
220
+ """
221
+ Set the user agent for the instance.
222
+
223
+ :param user_agent: The user agent string to set.
224
+ :return: None
225
+ """
187
226
  self._user_agent = user_agent
188
227
 
189
228
  def reset_user_agent(self):
229
+ """
230
+ Reset the user agent to None.
231
+
232
+ :return:
233
+ """
190
234
  self._user_agent = None
191
235
 
192
236
  def _add_user_agent(self, data):
@@ -197,4 +241,11 @@ class UserAgent(Capmonster):
197
241
  return data, False
198
242
 
199
243
  def set_fallback_to_actual_user_agent(self, fallback: bool):
244
+ """
245
+ Set the fallback value for the actual user agent.
246
+
247
+ :param fallback: A boolean value indicating whether to enable or disable the fallback.
248
+ :type fallback: bool
249
+ :return: None
250
+ """
200
251
  self._fallback = fallback
@@ -1,16 +1,17 @@
1
1
  from .capmonster import UserAgent
2
2
 
3
+
3
4
  class ComplexImageTask(UserAgent):
4
5
  def __init__(self, client_key):
5
6
  super(ComplexImageTask, self).__init__(client_key)
6
-
7
+
7
8
  def create_task(self, _class: str, grid: str = None,
8
9
  task_definition: str = None,
9
10
  image_urls: list = None,
10
11
  images_base64: list = None,
11
12
  task: str = None,
12
13
  websiteUrl: str = None):
13
- if _class is not "recaptcha" or _class is not "hcaptcha":
14
+ if _class != "recaptcha" or _class != "hcaptcha":
14
15
  raise ValueError("Currently only recaptcha or hcaptcha is supported as _class value.")
15
16
  data = {
16
17
  "clientKey": self._client_key,
@@ -26,7 +27,7 @@ class ComplexImageTask(UserAgent):
26
27
  data["task"]["imagesBase64"] = images_base64
27
28
  else:
28
29
  raise ValueError("image_urls or images_base64 must be sent")
29
- if _class is "recaptcha":
30
+ if _class == "recaptcha":
30
31
  if grid is None:
31
32
  raise ValueError("Grid parameter must sent with recaptcha")
32
33
  else:
@@ -37,7 +38,7 @@ class ComplexImageTask(UserAgent):
37
38
  data["task"]["metadata"]["TaskDefinition"] = task_definition
38
39
  else:
39
40
  raise ValueError("task_definition or task parameter must be sent")
40
- elif _class is "hcaptcha":
41
+ elif _class == "hcaptcha":
41
42
  if task is not None:
42
43
  data["task"]["metadata"]["Task"] = task
43
44
  else:
@@ -45,4 +46,4 @@ class ComplexImageTask(UserAgent):
45
46
  if websiteUrl is not None:
46
47
  data["task"]["websiteUrl"] = websiteUrl
47
48
  data, is_user_agent = self._add_user_agent(data)
48
- return self._make_request("createTask", data).get("taskId")
49
+ return self._make_request("createTask", data).get("taskId")
@@ -0,0 +1,19 @@
1
+ from .capmonster import UserAgent
2
+
3
+
4
+ class DataDomeTask(UserAgent):
5
+ def __init__(self, client_key):
6
+ super(DataDomeTask, self).__init__(client_key)
7
+
8
+ def create_task(self, website_url: str, metadata: object):
9
+ data = {
10
+ "client_key": self._client_key,
11
+ "task": {
12
+ "type": "CustomTask",
13
+ "class": "DataDome",
14
+ "websiteURL": website_url,
15
+ "metadata": metadata,
16
+ }
17
+ }
18
+ data, is_user_agent = self._add_user_agent(data)
19
+ return self._make_request("createTask", data=data).get("taskId")
@@ -1,12 +1,13 @@
1
- from .capmonster import Proxy, UserAgent
2
1
  from typing import Union
2
+ from .capmonster import Proxy, UserAgent
3
+
3
4
 
4
5
  class RecaptchaV2EnterpriseTask(UserAgent, Proxy):
5
6
  def __init__(self, client_key):
6
7
  super(RecaptchaV2EnterpriseTask, self).__init__(client_key)
7
8
 
8
9
  def create_task(self, website_url: str, website_key: str,
9
- enterprise_payload = None, api_domain: str = None,
10
+ enterprise_payload=None, api_domain: str = None,
10
11
  cookies: Union[dict, list, str] = None,
11
12
  no_cache: bool = None):
12
13
  data = {
@@ -17,7 +17,7 @@ def check_response():
17
17
  @wraps(f)
18
18
  def wrap(*args, **kwargs):
19
19
  rf = f(*args, **kwargs)
20
- if type(rf) == dict:
20
+ if type(rf) is dict:
21
21
  if rf.get("errorId") == 0:
22
22
  return rf
23
23
  else:
@@ -29,5 +29,7 @@ def check_response():
29
29
  error_code="CAPMONSTER_API_ERROR",
30
30
  error_description="Sometimes can be happen if capmonster_python "
31
31
  "servers there is too much intensity")
32
+
32
33
  return wrap
34
+
33
35
  return checker
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: capmonster_python
3
- Version: 2.5.0
3
+ Version: 2.6.1
4
4
  Summary: capmonster.cloud library for Python
5
5
  Home-page: https://github.com/alperensert/capmonster_python
6
6
  Author: Alperen Sert
@@ -29,20 +29,23 @@ Requires-Dist: six
29
29
 
30
30
  Capmonster.cloud for Python
31
31
  =
32
- ![PyPI - Wheel](https://img.shields.io/pypi/wheel/capmonster-python?style=plastic) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/capmonster_python?style=flat) ![GitHub last commit](https://img.shields.io/github/last-commit/alperensert/capmonster_python?style=flat) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/alperensert/capmonster_python?style=flat) ![PyPI - Downloads](https://img.shields.io/pypi/dm/capmonster_python?style=flat) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/alperensert/capmonster_python?style=flat) ![GitHub Repo stars](https://img.shields.io/github/stars/alperensert/capmonster_python?style=social)
32
+ ![PyPI - Wheel](https://img.shields.io/pypi/wheel/capmonster-python?style=plastic) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/capmonster_python?style=flat) ![GitHub last commit](https://img.shields.io/github/last-commit/alperensert/capmonster_python?style=flat) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/alperensert/capmonster_python?style=flat) ![PyPI - Downloads](https://img.shields.io/pypi/dm/capmonster_python?style=flat) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/alperensert/capmonster_python?style=flat) ![GitHub Repo stars](https://img.shields.io/github/stars/alperensert/capmonster_python?style=social)
33
33
 
34
34
  [Capmonster.cloud](https://capmonster.cloud) package for Python3
35
35
 
36
- If you have any problem with usage, [read the documentation](https://alperensert.github.io/capmonster_python) or [create an issue](https://github.com/alperensert/capmonster_python/issues/new)
36
+ If you have any problem with usage, [read the documentation](https://alperensert.github.io/capmonster_python)
37
+ or [create an issue](https://github.com/alperensert/capmonster_python/issues/new)
37
38
 
38
39
  *At least 2x cheaper, up to 30x faster than manual recognition services.*
39
40
 
40
41
  ### Installation
42
+
41
43
  ```
42
44
  pip install capmonster_python
43
45
  ```
44
46
 
45
47
  ### Supported captcha types
48
+
46
49
  - Image to text
47
50
  - Recaptcha v2
48
51
  - Recaptcha v2 Enterprise
@@ -51,6 +54,7 @@ pip install capmonster_python
51
54
  - HCaptcha
52
55
  - GeeTest
53
56
  - Turnstile Task
57
+ - Data Dome
54
58
 
55
59
  Usage examples
56
60
  -
@@ -95,7 +99,7 @@ from capmonster_python import GeeTestTask
95
99
 
96
100
  capmonster = GeeTestTask("API_KEY")
97
101
  task_id = capmonster.create_task("website_url", "gt", "challenge")
98
- result= capmonster.join_task_result(task_id)
102
+ result = capmonster.join_task_result(task_id)
99
103
  print(result.get("challenge"))
100
104
  print(result.get("seccode"))
101
105
  print(result.get("validate"))
@@ -5,6 +5,7 @@ setup.py
5
5
  capmonster_python/__init__.py
6
6
  capmonster_python/capmonster.py
7
7
  capmonster_python/compleximage.py
8
+ capmonster_python/datadome.py
8
9
  capmonster_python/fun_captcha.py
9
10
  capmonster_python/geetest.py
10
11
  capmonster_python/hcaptcha.py
@@ -1,13 +1,13 @@
1
1
  from distutils.core import setup
2
2
  from os import path
3
+
3
4
  this_directory = path.abspath(path.dirname(__file__))
4
5
  with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
5
6
  long_description = f.read()
6
7
 
7
-
8
8
  setup(
9
9
  name="capmonster_python",
10
- version="2.5.0",
10
+ version="2.6.1",
11
11
  packages=["capmonster_python"],
12
12
  url="https://github.com/alperensert/capmonster_python",
13
13
  long_description=long_description,