1

i am using python-requests on python 2.7, i am trying to authenticate against a web-server that returns multiple set-cookie headers in the response. python-requests keeps only one of those cookies.

i couldn't find a python 'http' client that either handles this problem correctly, or allows access to the raw header with the 'set-cookie' statements in order to manually deal with the problem.

i found a few statements in the internet that claim that this problem was solved in python3, however no further details or examples were provided.

would appreciate any assistance.

thanks

4

1 回答 1

1

可以通过请求获取 Set-Cookie-Header。

import requests
r = requests.get("http://localhost:5000")  
# a flask application there sets two cookies 'first' and 'second'

r.cookies.keys()
# returns ['first', 'second']

r.headers['Set-Cookie']
# returns 'first=4; Path=/, second=42; Path=/'

请显示一些您所做的代码,看看为什么它不适合您。

于 2013-04-28T16:31:25.507 回答