Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear cookies in scrapy?

By default, scrapy stores and passes cookies along requests. But how do I access or clear the stored cookies at certain point in the spider? Thanks?

like image 308
maxwell Avatar asked Feb 21 '14 02:02

maxwell


1 Answers

to set cookies to a specific request use request cookies field for example from docs:

request_with_cookies = Request(url="http://www.example.com",
                               cookies={'currency': 'USD', 'country': 'UY'})

do access request cookies:

request.headers.getlist('Cookie')

response cookies:

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

for more details see cookies middleware

like image 126
Guy Gavriely Avatar answered Nov 01 '22 07:11

Guy Gavriely