So I am trying to write up a small script with the requests
library that makes a request to a site (eg. github.com), and parses the cookies in the response headers. So when you make a request to github.com, there are 3 different Set-Cookie
headers as:
Set-Cookie: has_recent_activity=1; path=/; expires=Thu, 27 Dec 2018 07:54:16 -0000
Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Mon, 27 Dec 2038 06:54:16 -0000; secure; HttpOnly
Set-Cookie: _gh_sess=MldFM3p...; path=/; secure; HttpOnly
Now, when you make a request via the requests
API and check the Set-Cookie
header via req.headers.get('Set-Cookie')
, all those cookie values get clumped into one as:
has_recent_activity=1; path=/; expires=Thu, 27 Dec 2018 07:54:16 -0000, logged_in=no; domain=.github.com; path=/; expires=Mon, 27 Dec 2038 06:54:16 -0000; secure; HttpOnly, _gh_sess=MldFM3p...; path=/; secure; HttpOnly
So my question is how can I obtain 3 distinctly separate intact cookies as it was sent by the server alongwith all cookie metadata information (maybe in form of a list)?
I am a novice to Python, so any help will be highly appreciated. Cheers!