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})

 




posted @ 2020-11-17 11:40  AngDH  阅读(2397)  评论(0编辑  收藏  举报