Python教程

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

本文主要是介绍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})

 



这篇关于python爬虫,scrapy,获取响应的cookie,获取返回的cookie的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!