3

I am trying to colve cloudflare turnstile captcha which is on website https://visa.vfsglobal.com/ind/en/pol/login using python selenium with 2captcha api.

i have used same method the 2captcha showed on their website but i am wondering why its not sloving in my case. 2captcha solution example is here https://2captcha.com/demo/cloudflare-turnstile on their website. i think in my case the website is more secured thats why its not easily sovable.

kindly have a look and lemme know either this is something possible or not. thanks

what i tried here is code.

bot.maximize_window()

time.sleep(40)

bot.find_element(By.ID, 'mat-input-0').send_keys('Appointment.004slots@gmail.com')
time.sleep(5)
bot.find_element(By.ID, 'mat-input-1').send_keys('Umar@1234')


site_key = "0x4AAAAAAACYaM3U_Dz-4DN1"
result = cloudflare_turnstile.getCode(bot.current_url, site_key)
print("Result : ", result['code'])


bot.execute_script("document.getElementsByName('cf-turnstile-response')[0].value= " + "'" + result['code'] + "'"
)

time.sleep(5)

bot.find_element(By.XPATH, "//button/span[contains(text(),' Sign In')]").click()

2captcha solver code is below


from twocaptcha import TwoCaptcha

solver = TwoCaptcha('api key')

def getCode(url, data_siteKey):
    try:
        result = solver.turnstile(
            sitekey=data_siteKey,
            url=url
        )``your text``
    except Exception as e:
        print(e)
        exit()

    return result```

1 Answers1

0

There are few more required parameters added by 2captcha to solve turnstile captcha

  • action The value of action parameter passed to turnstile.render call
  • data The value of cData passed to turnstile.render call
  • pagedata The value of chlPageData passed to turnstile.render call
  • useragent The User-Agent of your browser

If you need to bypass the Turnstile on Cloudflare Challenge pages you also MUST provide the following additional parameters:

  1. action
  2. data
  3. pagedata
  4. useragent

See below the info how to extract the required parameters.

For cases when Turnstile is used standalone on a website, these parameters are optional.

How to extract the turnstile.render call parameters To extract the required parameters you can redefine the turnstile.rended method to intercept the parameters passed when the method is called. For example, you can inject the following JavaScript code to the page. The code should be executed before the Turnstile widget is loaded.

const i = setInterval(()=>{
    if (window.turnstile) {
        clearInterval(i)
        window.turnstile.render = (a,b) => {
            console.log(b)
            return 'foo'
        } 
    }
},50)

https://2captcha.com/blog/bypass-cloudflare-turnstile-captcha