-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_solver.py
46 lines (38 loc) · 1.63 KB
/
test_solver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import asyncio
import aiohttp
import time
async def test_solver():
url = "http://localhost:5000/solve"
payload = {
"url": "https://www.google.com/recaptcha/api2/demo",
"sitekey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
"headless": True,
"debug": False,
"check_score": False
}
print(f"Sending request to solver at {url}")
print(f"Testing with payload: {payload}")
start_time = time.time()
try:
async with aiohttp.ClientSession() as session:
async with session.post(url, json=payload, timeout=300) as response: # 5 min timeout
solve_time = time.time() - start_time
result = await response.json()
print(f"\nResponse status: {response.status}")
if response.status == 200 and result.get("success"):
token = result["token"]
print(f"\nSuccess! Solved in {solve_time:.2f} seconds")
print(f"Token length: {len(token)}")
print(f"Token preview: {token[:50]}...")
else:
error = result.get('error', 'Unknown error')
print(f"\nSolver failed: {error}")
print(f"Full response: {result}")
except asyncio.TimeoutError:
print("\nRequest timed out after 5 minutes")
except aiohttp.ClientError:
print("\nFailed to connect to solver API. Is the server running?")
except Exception as e:
print(f"\nUnexpected error: {str(e)}")
if __name__ == "__main__":
asyncio.run(test_solver())