I´m new to Python and I don´t even know if I´m asking correctly, but the thing is that I need to send a request to a site to log in and this site is returning me a message telling me that I must enable javascript before use that website.
I did it with Selenium and everything is ok, working fine (more stuff, not only the log in) but now I want to make it without Selenium, actually without any browser window, is this even possible? I guess it´s, but well, I need some help with this as I´m not finding the way to do it.
#!/usr/bin/python3
import requests
userEmail = "xxxxxxxxxxx@xxxxxxxxx.com" #using real data in the script
userPass = "xxxxxxxxxxxxx" #using real data in the script
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With': 'XMLHttpRequest'
}
def main():
r = requests.post('https://www.thedomain.com/en/customer/account/loginPost/',
data = {'login[username]':userEmail, "login[password]":userPass}, headers=headers)
print(r.text)
if __name__ == "__main__": main()
And this is the message I get:
<html>
<title>You are being redirected...</title>
<noscript>Javascript is required. Please enable javascript before you are allowed to see this page.</noscript>
</html>
Can I bypass this without Selenium?