如何在 Scrapy 中使用带有密码的 PROXY_LIST? [英] How to use PROXY_LIST with password in Scrapy?
本文介绍了如何在 Scrapy 中使用带有密码的 PROXY_LIST?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用不同的代理以避免被禁止.
I need to use different proxies to avoid being banned.
我把我的代理放在 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
我在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
},
}
这个版本在我的代理没有密码时工作
现在我有每个代理的密码,我如何更改它以使用密码?
Now i have the password for each proxy, how can i change it for working with password ?
推荐答案
我自己回答问题.
我使用它并且它有效:
http://USERNAME:PASSWORD@PROXYIP:PROXYPORT
这篇关于如何在 Scrapy 中使用带有密码的 PROXY_LIST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文