Reputation: 152
I've seen many topics asking to get cookies after a request has been made but I want the cookies Python sends out to a website. I have a site (site.com
) where if you go to they give you an Authorization
cookie. This is not in the response cookies but it's in the request cookies on Firefox Network activity. I'm wondering, is it posible to get the cookies sent with a request to a site?
I've tried:
import requests
session = requests.Session()
session.get("site.com")
print(session.cookies.get_dict())
But that didn't give me the request cookies
Upvotes: 2
Views: 6514
Reputation:
I do this and it does work.
>>> import requests
>>> session = requests.Session()
>>> print(session.cookies.get_dict())
{}
>>> response = session.get('http://google.com')
>>> print(session.cookies.get_dict())
{'PREF': 'ID=5514c728c9215a9a:FF=0:TM=1406958091:LM=1406958091:S=KfAG0U9jYhrB0XNf', 'NID': '67=TVMYiq2wLMNvJi5SiaONeIQVNqxSc2RAwVrCnuYgTQYAHIZAGESHHPL0xsyM9EMpluLDQgaj3db_V37NjvshV-eoQdA8u43M8UwHMqZdL-S2gjho8j0-Fe1XuH5wYr9v'}
Thanks
Upvotes: 1