Skip to content

Commit 369f4ed

Browse files
committed
v1.2
1 parent ba24f7d commit 369f4ed

File tree

6 files changed

+33
-36
lines changed

6 files changed

+33
-36
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66
#dynamic = ["version"]
77
dynamic = ["dependencies"]
88
name = "turnstile_solver"
9-
version = "0.3b"
9+
version = "1.2"
1010
description = "Python server to automatically solve Cloudflare Turnstile CAPTCHA with an average solving time of two seconds"
1111
readme = "README.md"
1212
authors = [{ name = "OGM" }]

src/turnstile_solver/main.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
__pname__ = "Turnstile Solver"
2929

3030
# mdata = metadata.metadata(__pname__)
31-
__version__ = "0.3b" # mdata['Version']
31+
__version__ = "1.2" # mdata['Version']
3232
__homepage__ = "https://github.com/odell0111/turnstile_solver" # mdata['Home-page']
3333
__author__ = "OGM" # mdata['Author']
3434
__summary__ = "Automatically solve Cloudflare Turnstile captcha" # mdata['Summary']
@@ -76,33 +76,33 @@ def positive_float(value):
7676
raise argparse.ArgumentTypeError(f'"{value}" is not a number')
7777
return value
7878

79-
# def positive_float_exclusive(value):
80-
# try:
81-
# value = float(value)
82-
# if value != -1 and value <= 0:
83-
# raise argparse.ArgumentTypeError(f"{value} is not a positive number")
84-
# except ValueError:
85-
# raise argparse.ArgumentTypeError(f'"{value}" is not a number')
86-
# return value
87-
#
88-
# def positive_integer_exclusive(value):
89-
# try:
90-
# value = int(value)
91-
# if value != -1 and value <= 0:
92-
# raise argparse.ArgumentTypeError(f"{value} is not a positive integer")
93-
# except ValueError:
94-
# raise argparse.ArgumentTypeError(f'"{value}" is not an integer')
95-
# return value
79+
def positive_float_exclusive(value):
80+
try:
81+
value = float(value)
82+
if value != -1 and value <= 0:
83+
raise argparse.ArgumentTypeError(f"{value} is not a positive number")
84+
except ValueError:
85+
raise argparse.ArgumentTypeError(f'"{value}" is not a number')
86+
return value
87+
88+
def positive_integer_exclusive(value):
89+
try:
90+
value = int(value)
91+
if value != -1 and value <= 0:
92+
raise argparse.ArgumentTypeError(f"{value} is not a positive integer")
93+
except ValueError:
94+
raise argparse.ArgumentTypeError(f'"{value}" is not an integer')
95+
return value
9696

9797
parser.add_argument("-p", "--production", action="store_true", help=f"Whether the project is running in a production environment or on a resource-constrained server, such as one that spins down during periods of inactivity.")
9898
parser.add_argument("-nn", "--no-ngrok", action="store_true", help=f"Do not use ngrok for keeping server alive on production.")
9999
parser.add_argument("-ncomp", "--no-computations", action="store_true", help=f"Do not simulate intensive computations for keeping server alive on production.")
100100
parser.add_argument("--headless", action="store_true", help=f"Open browser in headless mode. WARNING: This feature has never worked so far, captcha always fail! It's here only in case it works on future version of Playwright.")
101101
parser.add_argument("-bep", "--browser-executable-path", help=f"Chromium-based browser executable path. If not specified, Patchright (Playwright) will attempt to use its bundled version. Ensure you are using a Chromium-based browser installed with the command `patchright install chromium`. Other browsers may be detected by Cloudflare, which could result in the CAPTCHA not being solved.")
102102
parser.add_argument("-bp", "--browser-position", type=int, nargs='*', metavar="x|y", default=c.BROWSER_POSITION, help=f"Browser position x, y. Default: {c.BROWSER_POSITION}. If the browser window is positioned beyond the screen's resolution, it will be inaccessible, behaving similar to headless mode.")
103-
parser.add_argument("-nfl", "--no-file-logs", action="store_true", help=f"Do not log to file '%HOME%/.turnstile_solver/logs.log'.")
104-
105-
# Solver
103+
parser.add_argument("-nfl", "--no-file-logs", action="store_true", help=f"Do not log to file '$HOME.turnstile_solver/logs.log'.")
104+
#
105+
# # Solver
106106
solver = parser.add_argument_group("Solver")
107107
solver.add_argument("-ma", "--max-attempts", type=positive_integer, metavar="N", default=c.MAX_ATTEMPTS_TO_SOLVE_CAPTCHA, help=f"Max attempts to perform to solve captcha. Default: {c.MAX_ATTEMPTS_TO_SOLVE_CAPTCHA}.")
108108
solver.add_argument("-cto", "--captcha-timeout", type=positive_float, metavar="N.", default=c.CAPTCHA_ATTEMPT_TIMEOUT, help=f"Max time to wait for captcha to solve before reloading page. Default: {c.CAPTCHA_ATTEMPT_TIMEOUT} seconds.")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import logging
22
import pytest
33

4-
from ..solver_console import SolverConsole
5-
from ..utils import init_logger, get_file_handler
6-
from ..constants import PROJECT_HOME_DIR
4+
from turnstile_solver.solver_console import SolverConsole
5+
from turnstile_solver.utils import init_logger, get_file_handler
6+
from turnstile_solver.constants import PROJECT_HOME_DIR
77

88
_console = SolverConsole()
99

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import logging
2-
32
import asyncio
4-
from concurrent.futures import ThreadPoolExecutor, as_completed
5-
63
import pytest
74
import requests
85

9-
from ..constants import HOST, PORT, SECRET
10-
from ..solver import TurnstileSolver
11-
from ..solver_console import SolverConsole
12-
from ..turnstile_solver_server import TurnstileSolverServer
6+
from concurrent.futures import ThreadPoolExecutor, as_completed
7+
from pathlib import Path
8+
9+
from turnstile_solver.constants import HOST, PORT, SECRET
10+
from turnstile_solver.solver import TurnstileSolver
11+
from turnstile_solver.solver_console import SolverConsole
12+
from turnstile_solver.turnstile_solver_server import TurnstileSolverServer
1313

1414
host = HOST
1515
port = PORT
@@ -35,10 +35,7 @@ def server(console: SolverConsole) -> TurnstileSolverServer:
3535

3636
@pytest.fixture
3737
def solver(server: TurnstileSolverServer) -> TurnstileSolver:
38-
EXECUTABLE_PATH = r"C:\Users\odell\AppData\Local\ms-playwright\chromium-1155\chrome-win\chrome.exe"
39-
# EXECUTABLE_PATH = r"C:\Users\odell\AppData\Local\ms-playwright\chromium_headless_shell-1148\chrome-win\headless_shell.exe"
40-
# EXECUTABLE_PATH = r"C:\Program Files\Chromium\Application\chrome.exe"
41-
# EXECUTABLE_PATH = None
38+
EXECUTABLE_PATH = Path.home() / "AppData/Local/ms-playwright/chromium-1155/chrome-win/chrome.exe"
4239

4340
s = TurnstileSolver(
4441
console=server.console,

0 commit comments

Comments
 (0)