Akash Rana
Akash Rana

Reputation: 3845

Not able to save cookies from a website using Python requests?

For the link : http://www.ibnlive.com/videos/world/

by using a web browser I can easily see the following cookies when page is loaded as shown :

enter image description here

But if I try to load the same cookies using python requests, it shows up as an empty dictionary :

import requests
s = requests.session()
connection = s.get('http://www.ibnlive.com/videos/world/')
print(s.cookies) # produces an empty dictionary

My question how can I get those cookies using a python script ?

Upvotes: 1

Views: 981

Answers (1)

Jashandeep Sohi
Jashandeep Sohi

Reputation: 5173

Because the cookie is not being set by http://www.ibnlive.com/videos/world/, but some other resource that the page is loading. Try looking at the headers for that url, you won't see any Set-Cookie headers.

Upvotes: 1

Related Questions