Search code examples
pythonhtmlpython-requestsrecaptchacaptcha

Is it possible to get a g-Recaptcha-Response value with python requests?


I'm trying to log into this website santillanaconnect.com with python requests, the problem is that I need to get the value of g-Recaptcha-Response to be able to log in (among some other things but those are not a problem). If I inspect element and search for g-Recaptcha-Response then I'll get:

<input type="hidden" id="g-Recaptcha-Response" name="g-Recaptcha-Response" value="long string">

I tried to make a get request to save the value in some variable, so that I could then make a post request with that token. The problem is that when I try to get the value of g-Recaptcha-Response from the html of the response the value doesn't show up, I already tried adding headers (because maybe it won't show up because python requests User-Agent is blacklisted / not common) but it still doesn't work

import requests

url = "https://www.santillanaconnect.com/Account/Login/?wtrealm=http%3A%2F%2Flms30.santillanacompartir.com%2Flogin%2Fcompartir%2F&wreply=https%3A%2F%2Flms30.santillanacompartir.com%2Flogin%2Fsso%2Floginconnect"

headers = {
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
    "Accept-Encoding": "gzip, deflate, br", 
    "Accept-Language": "es-ES,es;q=0.9", 
    "Dnt": "1",
    "Upgrade-Insecure-Requests": "1", 
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.57"
}

with requests.Session() as s:
     
    r = s.get(url, headers=headers)
    print (r.text)

Solution

  • https://security.stackexchange.com/questions/238333/how-can-i-bypass-recaptcha-while-using-python-requests

    "You can not bypass a recaptcha, unless as @schroeder stated, where there is a weakness or an option on the site where you can bypass it. You might have to do some experimenting to see and find out if this is the case.

    A more exact solution involves multiple requests, as well as requests to other websites. First make a request that causes the recaptcha to appear. Then take the received info and send a web request via python, to a re-captcha third party solving service, that accepts recaptcha question data from online requests. Then from the answers you get back from them, send that as requests via python back to where it answers are sent for recaptcha questions. This way you are solving the recaptchas by sending requests via python. hYou still are not bypassing, however you are sending requests via python to get thru the recaptcha.

    Another solution for python might be able to solve the recaptcha, and send a request so that the recaptcha is passed. Basically when you solve a recaptcha, your results are sent via POST request. Although not exactly a 100% answer to your question, but it does involve sending requests via python.

    Solving the recaptcha in using python however would require intense machine learning, precise image recognition, and AI programing knowledge, most of those are probably still not yet at par 100% to successfully do every captcha. Also, the recaptcha was designed also to be difficult for bots to solve even" - Amol Soneji