import time, requests
class UnlockAPI:
def __init__(self, key, base="https://unlock-api.com"):
self.key, self.base = key, base
def _post(self, method, **body):
r = requests.post(f"{self.base}/{method}", json={"clientKey": self.key, **body}, timeout=30).json()
if r.get("errorId"):
raise RuntimeError(r.get("errorCode")) # failed tasks are refunded
return r
def balance(self):
return self._post("getBalance")["balance"]
def solve(self, task, timeout=300):
task_id = self._post("createTask", task=task)["taskId"]
end = time.time() + timeout
while time.time() < end:
time.sleep(5)
r = self._post("getTaskResult", taskId=task_id)
if r["status"] == "ready":
return r["solution"]
raise TimeoutError(task_id)Cách dùng
api = UnlockAPI("YOUR_API_KEY")
sol = api.solve({"type": "TurnstileTaskProxyless", "websiteURL": "https://example.com", "websiteKey": "0x4AAAA..."})
print(sol["token"])Dùng thư viện bạn đang có
Hầu hết thư viện giải CAPTCHA cho phép đổi địa chỉ server. Đặt thành unlock-api.com (hoặc https://unlock-api.com/in.php cho API form) và dùng UNLOCK API key của bạn. Tên tác vụ và phản hồi giữ nguyên.