Spaces:
Sleeping
Sleeping
Commit
•
94cc940
1
Parent(s):
bf5350c
Upload api.py
Browse files
api.py
CHANGED
@@ -7,18 +7,21 @@ from playwright.async_api import async_playwright
|
|
7 |
|
8 |
import hcaptcha_solver
|
9 |
|
10 |
-
app = Flask(__name__)
|
11 |
-
user_data_dir = Path(__file__).parent.joinpath("user_data_dir")
|
12 |
-
context_dir = user_data_dir.joinpath("context")
|
13 |
-
|
14 |
|
15 |
async def getcontext():
|
16 |
async with async_playwright() as p:
|
17 |
-
|
18 |
user_data_dir=context_dir,
|
19 |
headless=True,
|
20 |
locale="en-US"
|
21 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
|
24 |
def get_ipaddr():
|
@@ -30,7 +33,6 @@ def get_ipaddr():
|
|
30 |
|
31 |
|
32 |
handler = flog.default_handler
|
33 |
-
context = getcontext()
|
34 |
|
35 |
|
36 |
def get_token():
|
@@ -86,7 +88,7 @@ def solver_captcha():
|
|
86 |
data = request.get_json(force=True, silent=True)
|
87 |
if not check_request(require_data, data):
|
88 |
return jsonify(msg="Unauthorized Request"), 403
|
89 |
-
return asyncio.run(hcaptcha_solver.bytedance(
|
90 |
|
91 |
|
92 |
app.run(host="0.0.0.0", port=7860)
|
|
|
7 |
|
8 |
import hcaptcha_solver
|
9 |
|
|
|
|
|
|
|
|
|
10 |
|
11 |
async def getcontext():
|
12 |
async with async_playwright() as p:
|
13 |
+
context0 = p.firefox.launch_persistent_context(
|
14 |
user_data_dir=context_dir,
|
15 |
headless=True,
|
16 |
locale="en-US"
|
17 |
)
|
18 |
+
return context0
|
19 |
+
|
20 |
+
|
21 |
+
user_data_dir = Path(__file__).parent.joinpath("user_data_dir")
|
22 |
+
context_dir = user_data_dir.joinpath("context")
|
23 |
+
contexts = getcontext()
|
24 |
+
app = Flask(__name__)
|
25 |
|
26 |
|
27 |
def get_ipaddr():
|
|
|
33 |
|
34 |
|
35 |
handler = flog.default_handler
|
|
|
36 |
|
37 |
|
38 |
def get_token():
|
|
|
88 |
data = request.get_json(force=True, silent=True)
|
89 |
if not check_request(require_data, data):
|
90 |
return jsonify(msg="Unauthorized Request"), 403
|
91 |
+
return asyncio.run(hcaptcha_solver.bytedance(contexts, data["host"], data["site_key"]))
|
92 |
|
93 |
|
94 |
app.run(host="0.0.0.0", port=7860)
|