To solve Turnstile CAPTCHAs using the CAPTCHAs.IO API, follow these steps:
-
Register and Obtain API Key:
- Sign up for an account on CAPTCHAs.IO and get your API key.
-
Install Necessary Libraries:
- Ensure you have the required libraries to make HTTP requests, such as requests in Python.
-
Create a CAPTCHA Solving Request:
- Use the API endpoint provided by CAPTCHAs.IO to submit the CAPTCHA solving request. The required parameters typically include the CAPTCHA type, site URL, and site key.
-
Parse and Use the Response:
- Once the CAPTCHA is solved, CAPTCHAs.IO will return a response with the CAPTCHA solution token. Use this token in your web request to bypass the CAPTCHA.
Here is an example in Python:
import requests
import time
# Your API key
api_key = 'YOUR_API_KEY'
# CAPTCHA details
site_url = 'https://example.com'
site_key = 'YOUR_TURNSTILE_SITE_KEY'
# Send CAPTCHA solving request
response = requests.post('https://api.captchas.io/in.php', data={
'key': api_key,
'method': 'turnstile',
'site_url': site_url,
'site_key': site_key
})
# Get the request ID
request_id = response.text.split('|')[1]
# Poll for the result
while True:
time.sleep(5) # Wait for 5 seconds before polling again
result = requests.get(f'https://api.captchas.io/res.php?key={api_key}&action=get&id={request_id}')
if result.text.split('|')[0] == 'OK':
captcha_solution = result.text.split('|')[1]
break
elif result.text == 'CAPCHA_NOT_READY':
continue
else:
raise Exception(f"Error: {result.text}")
# Use the CAPTCHA solution token
print(f'CAPTCHA Solution: {captcha_solution}')
Key Points:
-
API Endpoint:
- Use the endpoint https://api.captchas.io/in.php to submit the CAPTCHA request.
- Use https://api.captchas.io/res.php to retrieve the solved CAPTCHA token.
-
Parameters:
- key: Your API key from CAPTCHAs.IO.
- method: Should be set to "turnstile".
- site_url: The URL of the page where the CAPTCHA is located.
- site_key: The site key of the Turnstile CAPTCHA.
-
Polling for Results:
- After submitting the CAPTCHA request, you need to poll for the result. CAPTCHAs.IO returns CAPCHA_NOT_READY if the CAPTCHA is still being solved.
-
Using the Solution:
- Once you get the CAPTCHA solution token, use it in the required field of your form submission to bypass the CAPTCHA.