python爬虫,scrapy,获取响应的cookie,获取返回的cookie

 

cookie_dict = {}
from scrapy.http.cookies import CookieJar
cookie_jar = CookieJar()
cookie_jar.extract_cookies(response, response.request)
# logging.info(' cookie_jar._cookies %s', cookie_jar._cookies)
for k, v in cookie_jar._cookies.items():
    for i, j in v.items():
        for m, n in j.items():
            cookie_dict[m] = n.value

 

 

 


 



cookie_jar.extract_cookies(response, response.request)
cookies = {}
for cookies_item in cookie_jar:
  cookies.update({cookies_item.name: cookies_item.value})

 




上一篇:Linux简单复习


下一篇:一文了解会话固定漏洞