From f334323e0520c304657784df69d6063f56c428bc Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Tue, 29 Apr 2014 18:00:17 -0400 Subject: [PATCH] Add proxy support --- tweepy/api.py | 5 ++++- tweepy/binder.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tweepy/api.py b/tweepy/api.py index 0e606ec..3d76646 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -19,7 +19,7 @@ class API(object): cache=None, api_root='/1.1', search_root='', retry_count=0, retry_delay=0, retry_errors=None, timeout=60, parser=None, compression=False, wait_on_rate_limit=False, - wait_on_rate_limit_notify=False): + wait_on_rate_limit_notify=False, proxy=None): self.auth = auth_handler self.host = host self.search_host = search_host @@ -34,6 +34,9 @@ class API(object): self.wait_on_rate_limit = wait_on_rate_limit self.wait_on_rate_limit_notify = wait_on_rate_limit_notify self.parser = parser or ModelParser() + self.proxy = {} + if proxy: + self.proxy['https'] = proxy """ statuses/home_timeline """ home_timeline = bind_api( diff --git a/tweepy/binder.py b/tweepy/binder.py index c1c58ea..4997cf6 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -154,7 +154,7 @@ def bind_api(**config): try: resp = self.session.request(self.method, full_url, data=self.post_data, timeout=self.api.timeout, - auth=auth) + auth=auth, proxies=self.api.proxy) except Exception, e: raise TweepError('Failed to send request: %s' % e) rem_calls = resp.headers.get('x-rate-limit-remaining') -- 2.25.1