aivarsk / scrapy-proxies

Random proxy middleware for Scrapy
MIT License
1.66k stars 409 forks source link

ValueError: All proxies are unusable, cannot proceed #28

Open irokhes opened 7 years ago

irokhes commented 7 years ago

I'm getting this error:

ValueError: All proxies are unusable, cannot proceed

2017-05-13 14:09:02 [scrapy.utils.log] INFO: Scrapy 1.3.3 started (bot: scrapy_bets) 2017-05-13 14:09:02 [scrapy.utils.log] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'scrapy_bets.spiders', 'FEED_URI': 'matches.json', 'SPIDER_MODULES': ['scrapy_bets.spiders'], 'RETRY_TIMES': 10, 'BOT_NAME': 'scrapy_bets', 'RETRY_HTTP_CODES': [500, 503, 504, 400, 403, 404, 408], 'FEED_FORMAT': 'json'} 2017-05-13 14:09:02 [scrapy.middleware] INFO: Enabled extensions: ['scrapy.extensions.feedexport.FeedExporter', 'scrapy.extensions.logstats.LogStats', 'scrapy.extensions.telnet.TelnetConsole', 'scrapy.extensions.corestats.CoreStats'] 2017-05-13 14:09:02 [scrapy.middleware] INFO: Enabled downloader middlewares: ['scrapy.downloadermiddlewares.retry.RetryMiddleware', 'scrapy_proxies.RandomProxy', 'scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware', 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware', 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware', 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware', 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware', 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware', 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware', 'scrapy.downloadermiddlewares.cookies.CookiesMiddleware', 'scrapy.downloadermiddlewares.stats.DownloaderStats'] 2017-05-13 14:09:02 [scrapy.middleware] INFO: Enabled spider middlewares: ['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware', 'scrapy.spidermiddlewares.offsite.OffsiteMiddleware', 'scrapy.spidermiddlewares.referer.RefererMiddleware', 'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware', 'scrapy.spidermiddlewares.depth.DepthMiddleware'] 2017-05-13 14:09:02 [scrapy.middleware] INFO: Enabled item pipelines: [] 2017-05-13 14:09:02 [scrapy.core.engine] INFO: Spider opened 2017-05-13 14:09:02 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min) 2017-05-13 14:09:02 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023 2017-05-13 14:09:02 [scrapy.core.scraper] ERROR: Error downloading <GET http://url_to_parse> Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1301, in _inlineCallbacks result = g.send(result) File "/usr/local/lib/python2.7/site-packages/scrapy/core/downloader/middleware.py", line 37, in process_request response = yield method(request=request, spider=spider) File "/usr/local/lib/python2.7/site-packages/scrapy_proxies/randomproxy.py", line 63, in process_request raise ValueError('All proxies are unusable, cannot proceed') ValueError: All proxies are unusable, cannot proceed 2017-05-13 14:09:02 [scrapy.core.scraper] ERROR: Error downloading <GET http://url_to_parse> Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1301, in _inlineCallbacks result = g.send(result) File "/usr/local/lib/python2.7/site-packages/scrapy/core/downloader/middleware.py", line 37, in process_request response = yield method(request=request, spider=spider) File "/usr/local/lib/python2.7/site-packages/scrapy_proxies/randomproxy.py", line 63, in process_request raise ValueError('All proxies are unusable, cannot proceed') ValueError: All proxies are unusable, cannot proceed 2017-05-13 14:09:02 [scrapy.core.engine] INFO: Closing spider (finished) 2017-05-13 14:09:02 [scrapy.statscollectors] INFO: Dumping Scrapy stats: {'downloader/exception_count': 2, 'downloader/exception_type_count/exceptions.ValueError': 2, 'finish_reason': 'finished', 'finish_time': datetime.datetime(2017, 5, 13, 13, 9, 2, 915138), 'log_count/DEBUG': 1, 'log_count/ERROR': 2, 'log_count/INFO': 7, 'scheduler/dequeued': 2, 'scheduler/dequeued/memory': 2, 'scheduler/enqueued': 2, 'scheduler/enqueued/memory': 2, 'start_time': datetime.datetime(2017, 5, 13, 13, 9, 2, 694730)} 2017-05-13 14:09:02 [scrapy.core.engine] INFO: Spider closed (finished)

mburke05 commented 7 years ago

reading the code, this appears like it's caused by either your having misplaced the file containing ips or you've presented a file that is parsed incorrectly.


        if len(self.proxies) == 0:
            raise ValueError('All proxies are unusable, cannot proceed')

self.proxies is just a dic that matches the regex:

'(\w+://)(\w+:\w+@)?(.+)'