I need to use different proxies to avoid being banned.
i read this question and this one
i put my proxies in proxylist.txt
http://xx.xx.xxx.xxx:port
http://xxx.xxx.xx.xxx:port
http://xx.xx.xxx.xxx:port
http://xxx.xxx.xx.xxx:port
and i set it in custom_settings
class MyClass(scrapy.Spider):
reload(sys)
sys.setdefaultencoding('utf8')
start_time = time.time()
name = 'mySpider'
custom_settings = {
'ROBOTSTXT_OBEY' : 'False',
'RETRY_TIMES' : 10,
'PROXY_LIST' : 'proxylist.txt',
'PROXY_MODE' : 0,
'DOWNLOADER_MIDDLEWARES' : {
'scrapy.downloadermiddlewares.retry.RetryMiddleware': 90,
'scrapy_proxies.RandomProxy': 100,
'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 110,
'scrapy_crawlera.CrawleraMiddleware': 600,
'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware': None,
'random_useragent.RandomUserAgentMiddleware': 400
},
}
this version worked when my proxies had no Passwords
Now i have the password for each proxy, how can i change it for working with password ?
I answer my own question.
I use this and it works: