Find reCAPTCHA parameters
A reCAPTCHA task needs websiteURL (the page showing the captcha) and websiteKey (the site key); v3 also needs pageAction. When you drive a browser with Selenium or similar, you also need the callback function. All of these can be found with the browser’s developer tools (F12).
The fastest way: a lookup script
Section titled “The fastest way: a lookup script”Open the page with the captcha, open the Console (F12), paste this and run it:
// Paste into the browser DevTools console on a page with reCAPTCHA, then run findRecaptchaClients().// Lists every reCAPTCHA on the page: version (V2/V3), sitekey, page URL and the callback function.function findRecaptchaClients() { if (typeof ___grecaptcha_cfg === 'undefined') return []; return Object.entries(___grecaptcha_cfg.clients).map(([cid, client]) => { const data = { id: cid, version: cid >= 10000 ? 'V3' : 'V2' }; const objects = Object.entries(client).filter(([, value]) => value && typeof value === 'object'); objects.forEach(([toplevelKey, toplevel]) => { const found = Object.entries(toplevel).find( ([, value]) => value && typeof value === 'object' && 'sitekey' in value && 'size' in value, ); if (toplevel instanceof HTMLElement && toplevel.tagName === 'DIV') data.pageurl = toplevel.baseURI; if (found) { const [sublevelKey, sublevel] = found; data.sitekey = sublevel.sitekey; const callbackKey = data.version === 'V2' ? 'callback' : 'promise-callback'; const callback = sublevel[callbackKey]; if (!callback) { data.callback = null; data.function = null; } else { data.function = callback; const keys = [cid, toplevelKey, sublevelKey, callbackKey].map((key) => `['${key}']`).join(''); data.callback = `___grecaptcha_cfg.clients${keys}`; } } }); return data; });}
findRecaptchaClients();In the output, sitekey is the websiteKey, pageurl is the websiteURL, version tells v2 from v3, and function and callback are the callback:
[ { "id": "0", "version": "V2", "sitekey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", "function": "onSuccess", "callback": "___grecaptcha_cfg.clients['0']['l']['l']['callback']", "pageurl": "https://www.google.com/recaptcha/api2/demo" }]An empty array means reCAPTCHA hasn’t loaded yet; run it again once the captcha appears.
websiteKey and websiteURL
Section titled “websiteKey and websiteURL”In the Network panel, search for anchor and find a request like:
https://www.google.com/recaptcha/api2/anchor?ar=1&k=6LfW6wATAAAAAHLqO2pb8bDBahxlMxNdo9g947u9&co=...&hl=en&size=normal- The value after
k=is thewebsiteKey. websiteURLis the full URL of the page showing the captcha (usually this request’sReferer).
You can also search the page source for data-sitekey.
pageAction (v3)
Section titled “pageAction (v3)”pageAction is the action the page passes in grecaptcha.execute(SITE_KEY, {action: '...'}), and it must match.
Method 1: search the source. In the Sources panel, right-click and choose “Search in all files”. Search .execute( for v3, or .enterprise.execute for v3 Enterprise, and look at the action that follows:
grecaptcha.ready(function () { grecaptcha.execute('6LdpS-gUAAAAAL3Qr2yP7rkrQjkKBVvEY_48JS5l', { action: 'login' }).then(function (token) { // ... });});Here pageAction is login.
Method 2: a breakpoint. If the code is obfuscated and search finds nothing, run debug(grecaptcha.execute) in the console (debug(grecaptcha.enterprise.execute) for Enterprise), then do whatever triggers verification on the page (for example click “Log in”). When the debugger stops, read action in the Scope panel.
A site may use different actions at different steps (for example signup/submit_email and then signup/success); use the one for the step you need to pass. Press F8 to continue to the next call.
Callback function
Section titled “Callback function”When you put a token into a page with Selenium or similar, you then call the page’s callback to tell it verification is complete:
- Search the Elements panel for
data-callback; its value is the function name, for exampledata-callback="onSuccess". - Or search for
grecaptcha.renderand read thecallbackoption. - Or inspect
___grecaptcha_cfg.clientsin the console, or use the lookup script above.
Calling it:
driver.execute_script("onSuccess(arguments[0])", g_recaptcha_response)Some pages have no callback; put the token into the g-recaptcha-response textarea and submit the form. The full flow: Submit a reCAPTCHA token.