requests返回值cookies轉字典

四不像程式猿發表於2020-11-04
import requests
url = 'http://www.porters.vip/verify/cookie/index.html'
res = requests.get(url=url)
print(type(res.cookies))
print(res.cookies)
cookiesdict = requests.utils.dict_from_cookiejar(res.cookies)
print(cookiesdict)

結果

<class 'requests.cookies.RequestsCookieJar'>
<RequestsCookieJar[<Cookie isfirst=789kq7uc1pp4c for www.porters.vip/verify/cookie>]>
{'isfirst': '789kq7uc1pp4c'}

相關文章