参考:
https://blog.csdn.net/sc_lilei/article/details/80702449

通过下载中间件里的process_exception(self, request, exception, spider)进行处理,如果捕获到response的status为500,404等,进行特殊处理,如果为200,就放行:

    @defer.inlineCallbacks
    def process_response(self, request, response, spider):

        if response.status == 500:
            # ...
            return request
        elif xxx