I want to use Python's requests module to login to the webpage https://www.tennistv.com/login.
I read this post on how to achieve this, however, I get stuck. The payload looks as follows:
payload = {"Email":"[MAIL]","Password":"[PASSWORD]"}
I then start a session as follows:
with requests.Session() as s:
p = s.post('https://www.tennistv.com/api/users/v1/login', data=payload, headers=headers)
# print the html returned or something more intelligent to see if it's a successful login page.
print(p.text)
This yields the following error:
{
"error": {
"validationErrors": [{
"key": "loginModel",
"value": [""]
}],
"errorMessage": "There was an error while validating input data (UR001)",
"errorCode": "UR001",
"userErrorCode": "UR001"
}
}
Even when I copy the request from Chrome's developer console as a cURL command and then execute the cURL command, I get the same error.
The cURL command looks as follows:
curl "https://www.tennistv.com/api/users/v1/login" -H "Pragma: no-cache" -H "Origin: https://www.tennistv.com" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36" -H "content-type: application/json" -H "Accept: */*" -H "Cache-Control: no-cache" -H "Referer: https://www.tennistv.com/login" -H "Connection: keep-alive" --data-binary "^{^\^"Email^\^":^\^"[MAIL]^\^",^\^"Password^\^":^\^"[PASS]^\^"^}" --compressed
What am I doing wrong? Where is the difference between the cURL command and the request sent by the browser?