-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability of report incorrect captchas
- Loading branch information
1 parent
13f4c3b
commit 9d21153
Showing
7 changed files
with
114 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
**/public | ||
**/.cache | ||
**/node_modules | ||
**/.DS_Store | ||
**/.DS_Store | ||
**/.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.autopep8" | ||
}, | ||
"python.formatting.provider": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from .capmonster import UserAgent | ||
|
||
class ComplexImageTask(UserAgent): | ||
def __init__(self, client_key): | ||
super(ComplexImageTask, self).__init__(client_key) | ||
|
||
def create_task(self, _class: str, grid: str = None, | ||
task_definition: str = None, | ||
image_urls: list = None, | ||
images_base64: list = None, | ||
task: str = None, | ||
websiteUrl: str = None): | ||
if _class is not "recaptcha" or _class is not "hcaptcha": | ||
raise ValueError("Currently only recaptcha or hcaptcha is supported as _class value.") | ||
data = { | ||
"clientKey": self._client_key, | ||
"task": { | ||
"type": "ComplexImageTask", | ||
"class": _class, | ||
"metadata": {} | ||
} | ||
} | ||
if image_urls is not None: | ||
data["task"]["imageUrls"] = image_urls | ||
elif images_base64 is not None: | ||
data["task"]["imagesBase64"] = images_base64 | ||
else: | ||
raise ValueError("image_urls or images_base64 must be sent") | ||
if _class is "recaptcha": | ||
if grid is None: | ||
raise ValueError("Grid parameter must sent with recaptcha") | ||
else: | ||
data["task"]["metadata"]["Grid"] = grid | ||
if task is not None: | ||
data["task"]["metadata"]["Task"] = task | ||
elif task_definition is not None: | ||
data["task"]["metadata"]["TaskDefinition"] = task_definition | ||
else: | ||
raise ValueError("task_definition or task parameter must be sent") | ||
elif _class is "hcaptcha": | ||
if task is not None: | ||
data["task"]["metadata"]["Task"] = task | ||
else: | ||
raise ValueError("task parameter must be sent with hcaptcha") | ||
if websiteUrl is not None: | ||
data["task"]["websiteUrl"] = websiteUrl | ||
data, is_user_agent = self._add_user_agent(data) | ||
return self._make_request("createTask", data).get("taskId") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters