bunnybun07 commited on
Commit
efd0161
·
verified ·
1 Parent(s): 5b63fa9

Create getCaptcha.py

Browse files
Files changed (1) hide show
  1. getCaptcha.py +26 -0
getCaptcha.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import time
3
+
4
+ def getTaskId():
5
+ url = "http://127.0.0.1:5000/turnstile?url=https://tenbin.ai/workspace&sitekey=0x4AAAAAABGR2exxRproizri&action=issue_execution_token"
6
+
7
+ response = requests.get(url)
8
+ response.raise_for_status()
9
+ return response.json()['task_id']
10
+
11
+ def getCaptcha(task_id):
12
+
13
+ url = f"http://127.0.0.1:5000/result?id={task_id}"
14
+
15
+ while True:
16
+ try:
17
+ response = requests.get(url)
18
+ response.raise_for_status()
19
+ captcha = response.json().get('value', None)
20
+ if captcha:
21
+ return captcha
22
+ else:
23
+ time.sleep(1)
24
+ except Exception as e:
25
+ print(e)
26
+ time.sleep(1)