Get cookie from CookieJar by name

后端 未结 4 1887
半阙折子戏
半阙折子戏 2021-01-03 19:46

I know that I can iterate through the cookies in a cookiejar, and this would allow me to find a cookie with a particular name - but does the CookieJar object itself have any

4条回答
  •  Happy的楠姐
    2021-01-03 20:45

    You can also use dict_from_cookiejar, which returns a key/value dictionary from a CookieJar. Something like:

    my_cookies = requests.utils.dict_from_cookiejar(s.cookies)
    

    and then access your cookie value by key.

提交回复
热议问题