简体   繁体   中英

scrapy - get cookies from response/request headers

I am trying to get the cookies from the request using this line of code but got [] empty result

response.headers.getList('Set-Cookie')

and this

response.request.headers.get('Cookie')

when I open_in_browser the response I inspect the Network tab and see the cookies exist (See image below)

在此处输入图片说明

在此处输入图片说明

Any Idea? Thank you

response.headers.getlist("Set-Cookie") works for me (Scrapy 1.4.0)

But first, check in shell if you actually have received this cookie:

scrapy shell
fetch('your_url')
response.headers.getlist("Set-Cookie")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM