Jul-27-2017, 08:38 AM
I used GET before with the Session() object to get the cookies.
These are the cookies which are sent when I log in from my browser (according to the Firefox developer tools):
Line 41 below shows that those cookies are set. I just added the "ushallpass" cookie myself in line 40.
Looking at the request headers sent from my browser, I have this:
I added those too, but I had to remove "Host", "Content-Length" because I didn't get a response otherwise. I also remove "Cookie" because I pass those either way.
I don't know what else to try. Does anyone have ideas?
Here's my current attempt with all the changes:
These are the cookies which are sent when I log in from my browser (according to the Firefox developer tools):
Quote:cookieKID "kid@[email protected]"
cookiePartner "kid@[email protected]"
ushallpass "true"
Line 41 below shows that those cookies are set. I just added the "ushallpass" cookie myself in line 40.
Looking at the request headers sent from my browser, I have this:
Quote:Host: login.mail.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://www.mail.com/int/
Content-Type: application/x-www-form-urlencoded
Content-Length: 358
Cookie: cookieKID=kid%40autoref%40mail.com; cookiePartner=kid%40autoref%40mail.com; ushallpass=true
Connection: keep-alive
Upgrade-Insecure-Requests: 1
I added those too, but I had to remove "Host", "Content-Length" because I didn't get a response otherwise. I also remove "Cookie" because I pass those either way.
I don't know what else to try. Does anyone have ideas?
Here's my current attempt with all the changes:
import requests user = "[email protected]" psswd = "fortesting" website = "https://www.mail.com" POST_url = "https://login.mail.com/login#.1258-header-login1-2" user_agent = "Mozilla/5.0 (Linux; Android 6.0.1; SM-G920V Build/MMB29K)" # from the POST request info from Firefox's developer tools params = { "service": "mailint", "uasServiceID": "mc_starter_mailcom", "successURL": "https://$(clientName)-$(dataCenter).mail.com/login", "loginFailedURL": "https://www.mail.com/int/logout/?ls=wd", "loginErrorURL": "https://www.mail.com/int/logout/?ls=te", "edition": "int", "lang": "en", "usertype": "standard", "username": "[email protected]", "password": "fortesting" } browser_headers = { # "Host": "login.mail.com", # "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate, br", "Referer": "https://www.mail.com/int/", "Content-Type": "application/x-www-form-urlencoded", # "Content-Length": "358", # "Cookie": "cookieKID=kid%40autoref%40mail.com; cookiePartner=kid%40autoref%40mail.com; ushallpass=true", "Connection": "keep-alive", "Upgrade-Insecure-Requests": "1", "User-Agent": user_agent } sess = requests.Session() sess.get(website, headers=browser_headers) sess.cookies["ushallpass"] = "true" print(sess.cookies) a = sess.post(POST_url, cookies=sess.cookies, headers=browser_headers, data=params) print(a.text)