-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
44 lines (39 loc) · 1.16 KB
/
main.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
from playwright.async_api import async_playwright
from solver import solver
from fastapi import FastAPI,Request
app = FastAPI()
@app.get("/")
async def root():
return {
"Status": 200,
"Data":{}
}
@app.post("/turnstile/{id:str}")
async def read_item(id:str,request:Request):
try:
body = await request.json()
sitekey:str = id
url:str = body['url']
invisible:bool = body['invisible']
print(url,sitekey)
if not url and not sitekey:
return {
"Status": 500,
"Data":{}
}
else:
async with async_playwright() as playwright:
cool_solver = solver.Solver(playwright, headless=True)
captcha = await cool_solver.solve(url,sitekey, invisible=invisible)
await cool_solver.terminate()
return {
"Status": 200,
"Data":{
"key":captcha
}
}
except Exception as e:
return {
"Status": 500,
"Data": {"error": str(e)}
}