Open HGYD opened 8 years ago
the problem may cause by this code
if 'proxy' in request.meta:
return
I deleted the code and fixed the problem.
I think when you retry, you already have a proxy in your request.meta, so the middleware just pass away.
Same issue
same +1
@aivarsk any chance you can update us on this?
Same issue
HGYD solution works for me.
I have similar issue of selecting new proxy like mentioned above, with my code after finishing retry attempts the code executions stops. Please suggest some solution
Here is the back trace
2017-07-06 18:54:45 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6042
2017-07-06 18:54:45 [scrapy.core.engine] INFO: Spider opened
2017-07-06 18:54:45 [scrapy.proxies] DEBUG: Using proxy http://72.169.78.1:87, 200 proxies left
2017-07-06 18:54:59 [scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET http://xyz.com> (failed 1 times): 403 Forbidden
2017-07-06 18:55:09 [scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET http://xyz.com> (failed 2 times): 403 Forbidden
2017-07-06 18:55:17 [scrapy.proxies] INFO: Removing failed proxy http://72.169.78.1:87, 199 proxies left
2017-07-06 18:55:17 [scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET http://xyz.com> (failed 3 times): [
Use errbacks in Requests:
def start_requests(self):
# ...
yield scrapy.Request(url=url, callback=self.parse, errback=self.make_new_request)
def make_new_request(self, failure):
return scrapy.Request(url=failure.request.url, callback=self.parse, errback=self.make_new_request, dont_filter=True)
What about setting a new proxy if a retry has happened? On line 81:
# Don't overwrite with a random one (server-side state for IP)
# But when randomizing every request, we do want to update the proxy on retry.
if not (self.mode == Mode.RANDOMIZE_PROXY_EVERY_REQUESTS and request.meta.get('retry_times', 0) == 0):
if 'proxy' in request.meta:
if request.meta["exception"] is False:
return
Hi, I use a proxies list to run my spider. However, it failed to pick a new porxy when the connection failure happens.
Please help to fix this problem. thanks a lot