Using Tweepy API Behind Proxy
Solution 1:
I guess you should set 'https_proxy' instead.
On my linux, I use this:
> export HTTPS_PROXY="http://xxxx:8888"
before running my Tweepy script.
Tweep uses 'requests' package for sending request, read http://docs.python-requests.org/en/master/user/advanced/#proxies for more.
Solution 2:
The proxy support in tweepy is severely lacking; there is a patch available that aims to fix that problem.
The patch switches Tweepy from using httplib
directly to using urllib2
instead, which means it'd honour the http_proxy
environment variable.
Solution 3:
EDIT: Turns out this isn't a viable answer, but I'm leaving it here for reference
Since a quick glance of the code shows that tweepy is using urllib2.urlopen & co., the easiest is possibly to just override the default opener...
# 'x.x.x.x' = IP of squid server
your_squid_server = urllib2.ProxyHandler({'http': 'x.x.x.x', 'https': 'x.x.x.x'})
new_opener = urllib2.build_opener(your_squid_server)
urllib2.install_opener(new_opener)
Haven't get an environment to check that at the moment though...
Do the above before importing tweepy to make sure the new opener is in effect
Solution 4:
this is an old question, but hopefully this helps.
https://bitbucket.org/sakito/tweepy provides tweepy with urllib merged into it; the proxy settings works well. there is a little problem with the stream (in my case, at least), but it is usable with a little tweak.
Post a Comment for "Using Tweepy API Behind Proxy"