I want to retry Scrapy request when if it gets an exception and the response status code is 429. The problem is I don't know how to get the response status on the process_exception
. How can I do it since it seems there is no way to access response object inside process_exception
?
class FakeUserAgentErrorRetryMiddleware(RetryMiddleware):
def process_exception(self, request, exception, spider):
if type(exception) == FakeUserAgentError: return self._retry(request, exception, spider)