I'm trying to login to this website using python. To login, the following parameters are required:
Content-Disposition: form-data; name="__RequestVerificationToken"
Content-Disposition: form-data; name="Username"
Content-Disposition: form-data; name="Password"
Content-Disposition: form-data; name="ufprt"
__RequestVerificationToken and ufprt can be obtained by making a get request to https://treat.com/SignIn
Username and Password are the login details
I'm triying the following code to get the request parameters
url = "https://treat.com/SignIn"
s = requests.Session()
response2 = s.get(url)
request_verification_token = BeautifulSoup(response2.text, 'html.parser').find('input', {'name': '__RequestVerificationToken'})['value']
ufprt = BeautifulSoup(response2.text, 'html.parser').find('input', {'name': 'ufprt'})['value']
I also store the cookie returned in the response
cookie = response2.cookies.get('__RequestVerificationToken')
Then the post request is built:
payload = {'__RequestVerificationToken': (None, request_verification_token),
'Username': (None, '<my_user>'),
'Password': (None, '<my_pass>'),
'ufprt': (None, ufprt)}
headers = {
'Cookie': cookie,
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br',
'Connection': 'keep-alive',
}
response3 = s.post(url, headers=headers, files=payload)
Request does not look bad
but I'm always getting an error 404 as shown

