So I'm trying to log into my hotmail account via python and keep getting this response on the page when I make this request
r = requests.post('https://login.live.com', auth=('Email', 'Pass'),verify=False)
Cookies must be allowed
Your browser is currently set to block cookies. Your browser must allow cookies before you can use a Microsoft account.
Cookies are small text files stored on your computer that tell Microsoft sites and services when you're signed in. To learn how to allow cookies, see online help in your web browser.
I would also like to mention that I am trying to httpPOST to this webpage because I would rather handle the cookies in the response and access other pages of my microsoft profile (rather than just accessing my email via the smtp server)
Thanks!
Edit :
import requests
s = requests.Session()
r = s.get('https://login.live.com',verify=False)
r = s.post('https://login.live.com', auth=('user', 'pass'),verify=False)
print r.status_code
print r.text
To send a request with a Cookie, you need to add the "Cookie: name=value" header to your request. To send multiple cookies in a single Cookie header, separate them with semicolons or add multiple "Cookie: name=value" request headers.
cookies module defines classes for abstracting the concept of cookies, an HTTP state management mechanism. It supports both simple string-only cookies, and provides an abstraction for having any serializable data-type as cookie value.
Open Google Chrome. From the web browser menu in the top-right corner, select Settings > Site settings > Cookies. From the Cookies menu, toggle the button on the right to Allow sites to save and read cookie data (recommended). Refresh the Chrome browser to enable cookies.
Use requests.Session
to persist a session (with cookies included):
import requests
s = requests.Session()
res = s.get('https://login.live.com')
cookies = dict(res.cookies)
res = s.post('https://login.live.com',
auth=('Email', 'Password'),
verify=False,
cookies=cookies)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With