-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauto_solve.py
More file actions
37 lines (26 loc) · 1.03 KB
/
Copy pathauto_solve.py
File metadata and controls
37 lines (26 loc) · 1.03 KB
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
"""Auto-solve example: open a Turnstile-protected page, captcha solves itself.
Requires a funsolver.com API key. Set it via FUNBROWSER_API_KEY or edit below.
FUNBROWSER_API_KEY=fs_xxx uv run python examples/auto_solve.py
"""
from __future__ import annotations
import asyncio
import os
import sys
import funbrowser
# A public Turnstile demo page. Replace with the site you're targeting.
DEMO_URL = "https://nopecha.com/demo/turnstile"
async def main() -> None:
api_key = os.environ.get("FUNBROWSER_API_KEY")
if not api_key:
print("Set FUNBROWSER_API_KEY first.", file=sys.stderr)
sys.exit(1)
async with await funbrowser.start(api_key=api_key) as browser:
tab = await browser.get(DEMO_URL)
# Give the detector + funsolver round-trip time to land.
await asyncio.sleep(30)
token = await tab.evaluate(
"document.querySelector('[name=\"cf-turnstile-response\"]')?.value || null"
)
print(f"token = {token!r}")
if __name__ == "__main__":
asyncio.run(main())