add ssl proxy support to browser and browser2 and add the option _proxy_ssl
This commit is contained in:
parent
a56767fbf5
commit
0f1726d01c
3 changed files with 26 additions and 14 deletions
|
|
@ -313,12 +313,31 @@ class BaseBackend(object):
|
|||
if not self.BROWSER:
|
||||
return None
|
||||
|
||||
tmpproxy = None
|
||||
tmpproxys = None
|
||||
|
||||
if '_proxy' in self._private_config:
|
||||
kwargs['proxy'] = self._private_config['_proxy']
|
||||
tmpproxy = self._private_config['_proxy']
|
||||
elif 'http_proxy' in os.environ:
|
||||
kwargs['proxy'] = os.environ['http_proxy']
|
||||
tmpproxy = os.environ['http_proxy']
|
||||
elif 'HTTP_PROXY' in os.environ:
|
||||
kwargs['proxy'] = os.environ['HTTP_PROXY']
|
||||
tmpproxy = os.environ['HTTP_PROXY']
|
||||
if '_proxys' in self._private_config:
|
||||
tmpproxys = self._private_config['_proxy_ssl']
|
||||
elif 'https_proxy' in os.environ:
|
||||
tmpproxys = os.environ['https_proxy']
|
||||
elif 'HTTPS_PROXY' in os.environ:
|
||||
tmpproxys = os.environ['HTTPS_PROXY']
|
||||
print tmpproxys
|
||||
|
||||
if tmpproxy is not None or tmpproxys is not None:
|
||||
kwargs['proxy'] = {}
|
||||
if tmpproxy is not None:
|
||||
kwargs['proxy']['http'] = tmpproxy
|
||||
if tmpproxys is not None:
|
||||
kwargs['proxy']['https'] = tmpproxys
|
||||
|
||||
|
||||
kwargs['logger'] = self.logger
|
||||
|
||||
if hasattr(self.BROWSER, 'SAVE_RESPONSES') and self.BROWSER.SAVE_RESPONSES and self.BROWSER.responses_dirname:
|
||||
|
|
|
|||
|
|
@ -223,15 +223,8 @@ class StandardBrowser(mechanize.Browser):
|
|||
|
||||
# Use a proxy
|
||||
self.proxy = proxy
|
||||
if proxy:
|
||||
proto = 'http'
|
||||
if '://' in proxy:
|
||||
v = urlsplit(proxy)
|
||||
proto = v.scheme
|
||||
domain = v.netloc
|
||||
else:
|
||||
domain = proxy
|
||||
self.set_proxies({proto: domain})
|
||||
if proxy is not None:
|
||||
self.set_proxies(proxy)
|
||||
|
||||
# Share cookies with firefox
|
||||
if firefox_cookies and HAVE_COOKIES:
|
||||
|
|
@ -481,7 +474,7 @@ class BaseBrowser(StandardBrowser):
|
|||
does not keep history
|
||||
:type history: object
|
||||
:param proxy: proxy URL to use
|
||||
:type proxy: str
|
||||
:type proxy: dictionnary
|
||||
:param logger: logger to use for logging
|
||||
:type logger: :class:`logging.Logger`
|
||||
:param factory: mechanize factory. None to use Mechanize's default
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class BaseBrowser(object):
|
|||
self.logger = getLogger('browser', logger)
|
||||
self._setup_session(self.PROFILE)
|
||||
if proxy is not None:
|
||||
self.session.proxies = {'http': proxy, 'https': proxy}
|
||||
self.session.proxies = proxy
|
||||
self.url = None
|
||||
self.response = None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue