tianping / getCaptcha.py
maltose1's picture
Upload 9 files
d498971 verified
raw
history blame contribute delete
823 Bytes
import requests
import time
import os
TURNSTILE_SOLVER_URL = os.environ.get("TURNSTILE_SOLVER_URL", "http://127.0.0.1:5000")
def getTaskId():
url = f"{TURNSTILE_SOLVER_URL}/turnstile?url=https://tenbin.ai/workspace&sitekey=0x4AAAAAABGR2exxRproizri&action=issue_execution_token"
response = requests.get(url)
response.raise_for_status()
return response.json()['task_id']
def getCaptcha(task_id):
url = f"{TURNSTILE_SOLVER_URL}/result?id={task_id}"
while True:
try:
response = requests.get(url)
response.raise_for_status()
captcha = response.json().get('value', None)
if captcha:
return captcha
else:
time.sleep(1)
except Exception as e:
print(e)
time.sleep(1)