maxwell maxwell - 6 months ago 69
Python Question

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?

Answer Source

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

request_with_cookies = Request(url="",
                               cookies={'currency': 'USD', 'country': 'UY'})

do access request cookies:


response cookies:


for more details see cookies middleware

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download