im having a problem with getting the parameters which 2captcha api needs to solve the captcha . The type of Captcha Im struggeling with, is Cloudflare Turnstile. There are two hidden parameters you need to get which are : *cdata *and *pagedata *. I have read 2captcha blog about Cloudflare Turnstile and how to get the parameters I need through a js code which is this :
const i = setInterval(() => {
if (window.turnstile) {
clearInterval(i);
window.turnstile.render = (a, b) => {
x = b;
return 'foo';
};
}
}, 50);
. and they have mentioned that I should run this code before the load of the cloudflare widget. But I am having problem with this code i gotta run on that specific time. I can not run this code on the page with Selenium or any other Module or Library that works on browser. How can i run this code on the right time ? preferebly in python. Thanx for helping.
I have tried any type of before load script injection on the page but they did not work. Such as : BroserMob Proxy and etc
I ran into this same issue. Try this extension - Custom JavaScript for Websites 2
Here's the js I added to the extension -
function getTurnstileParams(){
console.log('getTurnstileParams has started');
if (window.turnstile) {
clearInterval(i)
window.turnstile.render = (a,b) => {
let p = {
method: "turnstile",
key: "YOUR API KEY",
sitekey: b.sitekey,
pageurl: window.location.href,
data: b.cData,
pagedata: b.chlPageData,
action: b.action,
json: 1
}
console.log(JSON.stringify(p))
//window.tsCallback = b.callback
return 'foo'
}
}
}
const i = setInterval(()=>{getTurnstileParams(); },50);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With