Python Requests-学习笔记(7)-Cookies

如果某个响应中包含一些Cookie,你可以快速访问它们:

url = 'http://example.com/some/cookie/setting/url'
r = requests.get(url)

r.cookies['example_cookie_name']

要想发送你的cookies到服务器,可以使用 cookies 参数:

url = 'http://httpbin.org/cookies'
cookies = dict(cookies_are='working')

r = requests.get(url, cookies=cookies)
r.text


 
posted @ 2016-03-01 15:20  逆风飞行  阅读(574)  评论(0编辑  收藏  举报