Find the sitekey
Where to find a Turnstile widget's sitekey, action and cdata on a page.
To solve Turnstile you need the widget's sitekey. Some sites also set an action and cdata. If they do, send them too, or the solve fails with invalid_action or invalid_cdata.
| Field | Looks like | Required |
|---|---|---|
sitekey | 0x4AAAAAAAB1cD2eF3gH4iJ5 | Yes |
action | Up to 32 letters, digits, _ or -, such as login | Only if the page sets one |
cdata | Up to 255 letters, digits, _ or -, such as session-8f2a | Only if the page sets one |
url | The full URL of the page | Yes |
Send url as the page that shows the widget, not the site's home page.
Real sitekeys start with 0x4. Sitekeys that start with 1x, 2x or 3x, such as 1x00000000000000000000AA, are Cloudflare's test sitekeys: the site is in testing mode and doesn't need a real solve.
You don't need any of this for the 5-Second Challenge (WAF). Peak Solutions reads it from the html you send.
In the page HTML
Most sites put the widget in the HTML as an element with data- attributes:
<div
class="cf-turnstile"
data-sitekey="0x4AAAAAAAB1cD2eF3gH4iJ5"
data-action="login"
data-cdata="session-8f2a"
></div>Open the page, view its source, and search for cf-turnstile. The data-sitekey, data-action and data-cdata on that element are the sitekey, action and cdata.
Search for cf-turnstile, not just data-sitekey: reCAPTCHA and hCaptcha widgets use data-sitekey too, and other scripts often use data-action for their own purposes.
Rendered with JavaScript
Other sites create the widget from a script, with turnstile.render():
turnstile.render('#captcha', {
sitekey: '0x4AAAAAAAB1cD2eF3gH4iJ5',
action: 'login',
cData: 'session-8f2a',
});Search the page's scripts for turnstile.render or for 0x4AAAA. Here the cdata option is spelled cData, but you send it to Peak Solutions as cdata.
With the browser console
On the page with the widget, open the developer tools (F12), go to Console, and run:
[...document.querySelectorAll('.cf-turnstile')].map((el) => ({
sitekey: el.dataset.sitekey,
action: el.dataset.action,
cdata: el.dataset.cdata,
}));It lists every widget written in the HTML. If it returns an empty list, or a widget without a sitekey, the widget was rendered with JavaScript: use the Network tab instead.
In the Network tab
Every widget loads a frame from challenges.cloudflare.com, with the sitekey in its URL.
- Open the developer tools (F12) and go to Network.
- Reload the page and filter by
challenges.cloudflare.com. - Find the request whose path contains
turnstile. The part of the path that starts with0x4is the sitekey.
This works even when the widget is hidden or created by a script.
In your code
If your code already loads the page, read the values out of the HTML before you solve:
import re
def find_turnstile(html: str) -> dict:
"""Returns the sitekey, action and cdata of the first Turnstile widget in the HTML."""
widget = re.search(r'<[^>]*cf-turnstile[^>]*>', html)
if not widget:
return {}
found = {}
for field in ("sitekey", "action", "cdata"):
match = re.search(rf'data-{field}=["']([^"']+)["']', widget.group(0))
if match:
found[field] = match.group(1)
return foundThen pass them into the task with the page url. If a field isn't found, leave it out of the task. If no widget is found at all, it was rendered with JavaScript: look for the turnstile.render() call in the page's scripts instead.
If the solve fails
error_code | What to check |
|---|---|
invalid_sitekey | The sitekey is copied in full, and belongs to the url you sent. |
invalid_action | The action matches the page exactly, or leave it out if the page has none. |
invalid_cdata | The cdata matches the page exactly. Some sites change it on every page load. |
If the site changes cdata on every load, read it again from the page right before each solve.