ability to set a proxy address
This commit is contained in:
parent
51b5d00b6e
commit
99c64d4849
1 changed files with 5 additions and 1 deletions
|
|
@ -129,7 +129,7 @@ class BaseBrowser(mechanize.Browser):
|
||||||
default_features.remove('_robots')
|
default_features.remove('_robots')
|
||||||
|
|
||||||
def __init__(self, username=None, password=None, firefox_cookies=None,
|
def __init__(self, username=None, password=None, firefox_cookies=None,
|
||||||
parser=None, history=NoHistory()):
|
parser=None, history=NoHistory(), proxy=None):
|
||||||
"""
|
"""
|
||||||
Constructor of Browser.
|
Constructor of Browser.
|
||||||
|
|
||||||
|
|
@ -146,6 +146,10 @@ class BaseBrowser(mechanize.Browser):
|
||||||
['User-agent', self.USER_AGENT]
|
['User-agent', self.USER_AGENT]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Use a proxy
|
||||||
|
if proxy:
|
||||||
|
self.set_proxies({"http": proxy})
|
||||||
|
|
||||||
# Share cookies with firefox
|
# Share cookies with firefox
|
||||||
if firefox_cookies and HAVE_COOKIES:
|
if firefox_cookies and HAVE_COOKIES:
|
||||||
self._cookie = FirefoxCookieJar(self.DOMAIN, firefox_cookies)
|
self._cookie = FirefoxCookieJar(self.DOMAIN, firefox_cookies)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue