Closed ChristianYeah closed 5 years ago
turns out you can do like this use getbool instead of get
class ProxyMiddleware(object):
def __init__(self, proxy_enabled, proxy_address):
self.proxy_enabled = proxy_enabled
self.proxy_address = proxy_address
@classmethod
def from_crawler(cls, crawler):
return cls(
# proxy_enabled=crawler.settings.get('LUMINATI_PROXY_ENABLED', False),
# use getbool method instead
proxy_enabled=crawler.settings.getbool('LUMINATI_PROXY_ENABLED', False),
proxy_address=crawler.settings.get('LUMINATI_PROXY_ADDRESS'),
)
def process_request(self, request, spider):
if self.proxy_enabled:
request.meta["proxy"] = self.proxy_address
return None
I have settings in the setting.py
In some case, I'd like to disable the proxy by passing LUMINATI_PROXY_ENABLED=False, like
however, based on the log, only built-in settings will be modified