...
经过 API 文档可以看到使用的时候可以配置如下参数:
参数名 | 是否必须 | 说明 |
---|---|---|
token | 是 | 请在个人中心获取 (Token) |
websiteKey | 是 | ReCaptcha SiteKey (固定参数) |
websiteURL | 是 | ReCaptcha Referer (一般也为固定参数) |
type | 否 | NoCaptchaTaskProxyless、RecaptchaV2TaskProxyless |
这里就有三个关键信息了:
token:就是刚才我们在 YesCaptcha 上复制下来的参数
websiteKey:这个是 ReCAPACHA 的标志字符串,稍后我们会演示怎么找。
websiteURL,一般是 ReCAPTCHA 的来源网站的 Referer,比如对于当前的案例,该值就是 https://www.google.com/recaptcha/api2/demo
...
代码块 |
---|
def polling_task(task_id): url = f"{BASE_URL}/getTaskResult" data = { "clientKey": TOKEN, "taskId": task_id } count = 0 while count < 120: try: response = requests.post(url, json=data, verify=False) if response.status_code == 200: result_data = response.json() print('polling result', result_data) status = result_data.get('solution', {}).get('status') print('status of task', status) if status == 'ready': return result_data.get('solution', {}).get('gRecaptchaResponse') except requests.RequestException as e: print('polling task failed', e) finally: count += 1 time.sleep(1) |
...