dont_merge_cookies docs are incomplete: they say that
When some site returns cookies (in a response) those are stored in the cookies for that domain and will be sent again in future requests. That’s the typical behaviour of any regular web browser. However, if, for some reason, you want to avoid merging with existing cookies you can instruct Scrapy to do so by setting the dont_merge_cookies key to True in the Request.meta.
But this flag not only prevents merging of cookies, but also prevents sending of them:
I mean that if i set dont_merge_cookies=true, scrapy will dont send any cookie to server.
But i just want that scrapy don't merge my cookies with the response's cookies, and continue to send my cookies to server.
defprocess_request(self, request, spider):
# set Cookie headerrequest.headers.pop('Cookie', None)
defprocess_response(self, request, response, spider):
returnresponse# extract cookies from Set-Cookie and drop invalid/expired cookiescookiejarkey=request.meta.get("cookiejar")
if I set dont_merge_cookies=true,scrapy will do nothing.
@Ferrer-Jeremy think code can be modify to