How to enable cookiemiddleware in scrapy in python
python, scrapy
Solution
update it would appear cookies are in the middleware by default, so just `COOKIES_ENABLED = True` should be sufficient. You only need the below if the middleware is not part of the defaults...
From what I can tell from doc.scrapy.org/en/latest/topics/downloader-middleware.html you add `'scrapy.contrib.downloadermiddleware.cookies.CookiesMiddleware'` to DOWNLOADER_MIDDLEWARE with a relevant ordering:
To activate a downloader middleware component, add it to the DOWNLOADER_MIDDLEWARES setting, which is a dict whose keys are the middleware class paths and their values are the middleware orders.
DOWNLOADER_MIDDLEWARES = {
'myproject.middlewares.CustomDownloaderMiddleware': 543,
'scrapy.contrib.downloadermiddleware.cookies.CookiesMiddleware': 700 # <-
}
The 700 comes from the default `DOWNLOADER_MIDDLEWARES_BASE` at http://doc.scrapy.org/en/latest/topics/downloader-middleware.html#built-in-downloader-middleware-reference Then put `COOKIES_ENABLED = True` (and optionally `COOKIES_DEBUG = True`) with the rest of your settings.
Problem
IN their documentation here http://doc.scrapy.org/en/latest/topics/downloader-middleware.html#cookies-mw They told to enable the cookie middle , but i am not able to find how to do that and which file to edit for that. Can anyone tell me how can i do that