playwright-captcha-solver 1.0.0__py3-none-any.whl
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.
- captcha_solver/__init__.py +36 -0
- captcha_solver/api_client.py +142 -0
- captcha_solver/captcha_reporter.py +18 -0
- captcha_solver/captcha_solver.py +67 -0
- captcha_solver/image_solver.py +127 -0
- captcha_solver/pipeline.py +106 -0
- captcha_solver/recaptcha_solver.py +161 -0
- captcha_solver/sdk_types.py +70 -0
- captcha_solver/submitter.py +65 -0
- playwright_captcha_solver-1.0.0.dist-info/METADATA +730 -0
- playwright_captcha_solver-1.0.0.dist-info/RECORD +14 -0
- playwright_captcha_solver-1.0.0.dist-info/WHEEL +5 -0
- playwright_captcha_solver-1.0.0.dist-info/licenses/LICENSE +38 -0
- playwright_captcha_solver-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Optional, Union, Literal
|
|
5
|
+
|
|
6
|
+
from playwright.async_api import Page, Locator
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# ==========================
|
|
10
|
+
# Authentication
|
|
11
|
+
# ==========================
|
|
12
|
+
|
|
13
|
+
@dataclass(slots=True)
|
|
14
|
+
class AuthToken:
|
|
15
|
+
authtoken: str
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(slots=True)
|
|
19
|
+
class Credentials:
|
|
20
|
+
username: str
|
|
21
|
+
password: str
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Authentication = Union[AuthToken, Credentials]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# ==========================
|
|
28
|
+
# CaptchaSolver Options
|
|
29
|
+
# ==========================
|
|
30
|
+
|
|
31
|
+
@dataclass(slots=True)
|
|
32
|
+
class CaptchaSolverOptions:
|
|
33
|
+
auth: Authentication
|
|
34
|
+
timeout: Optional[int] = None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# ==========================
|
|
38
|
+
# Solve Options
|
|
39
|
+
# ==========================
|
|
40
|
+
|
|
41
|
+
@dataclass(slots=True)
|
|
42
|
+
class ImageChallenge:
|
|
43
|
+
page: Page
|
|
44
|
+
captcha: Locator
|
|
45
|
+
input: Locator
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(slots=True)
|
|
49
|
+
class RecaptchaChallenge:
|
|
50
|
+
page: Page
|
|
51
|
+
proxy: Optional[str] = None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
SolveOptions = Union[
|
|
55
|
+
ImageChallenge,
|
|
56
|
+
RecaptchaChallenge,
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# ==========================
|
|
61
|
+
# Solve Result
|
|
62
|
+
# ==========================
|
|
63
|
+
|
|
64
|
+
@dataclass(slots=True)
|
|
65
|
+
class SolveResult:
|
|
66
|
+
success: bool
|
|
67
|
+
challenge: Literal["image", "recaptcha"]
|
|
68
|
+
duration: int
|
|
69
|
+
id: Optional[str]
|
|
70
|
+
balance: Optional[float]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from playwright.async_api import Locator, Page
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Submitter:
|
|
5
|
+
async def submit_image(
|
|
6
|
+
self,
|
|
7
|
+
page: Page,
|
|
8
|
+
input: Locator,
|
|
9
|
+
solution: str,
|
|
10
|
+
) -> None:
|
|
11
|
+
|
|
12
|
+
print(page)
|
|
13
|
+
print(solution)
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
await input.fill(solution)
|
|
17
|
+
|
|
18
|
+
if await input.input_value() != solution:
|
|
19
|
+
try:
|
|
20
|
+
await input.press("Control+A")
|
|
21
|
+
except Exception:
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
await input.press("Meta+A")
|
|
26
|
+
except Exception:
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
await input.press("Backspace")
|
|
30
|
+
await input.press_sequentially(solution)
|
|
31
|
+
|
|
32
|
+
print("Captcha solved successfully.")
|
|
33
|
+
|
|
34
|
+
except Exception as exc:
|
|
35
|
+
print(f"Text submission failed: {exc}")
|
|
36
|
+
|
|
37
|
+
async def submit_recaptcha(
|
|
38
|
+
self,
|
|
39
|
+
page: Page,
|
|
40
|
+
token: str,
|
|
41
|
+
) -> None:
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
await page.evaluate(
|
|
45
|
+
"""
|
|
46
|
+
(token) => {
|
|
47
|
+
const textarea =
|
|
48
|
+
document.querySelector("#g-recaptcha-response");
|
|
49
|
+
|
|
50
|
+
textarea.value = token;
|
|
51
|
+
|
|
52
|
+
textarea.dispatchEvent(
|
|
53
|
+
new Event("input", {
|
|
54
|
+
bubbles: true
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
""",
|
|
59
|
+
token,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
print("Captcha solved successfully.")
|
|
63
|
+
|
|
64
|
+
except Exception as exc:
|
|
65
|
+
print(f"Token submission failed: {exc}")
|