How Tweepy works for proxies

I am very new to python. So I could not figure out the earlier posts. I use the sample code below to swallow twitter streaming when I'm not following a proxy server, this works fine, but when I go to a proxy server, it doesn't work. would be a great help if someone can help me get around the proxy in this code

tp = TwitterHandler()
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
stream = tweepy.Stream(auth, tp)

stream.filter(track=FILTER_WORDS_LIST)
+4
source share
2 answers

I looked through this link to start with tweepy - http://adilmoujahid.com/posts/2014/07/twitter-analytics/

I am also stuck with a proxy problem. That's how I solved it -

In your Windows terminal

set http_proxy=http://username:password@host:port

set https_proxy=https://username:password@host:port

then run the file as indicated in the link above -

python twitter_streaming.py

- -

,

+1

, , tweepy :

import tweepy

class ProxyStream(tweepy.Stream):

    def new_session(self):

        super().new_session() # PY2: super(ProxyStream, self).new_session()
        self.session.proxies = {
            'https': 'http://proxy1:3128',
            'http': 'http://proxy1:3128'
        }

, ProxyStream tweepy.Stream, :

auth = tweepy.OAuthHandler('TWITTER_CONSUMER_KEY', 'TWITTER_CONSUMER_SECRET')
auth.set_access_token('TWITTER_ACCESS_TOKEN', 'TWITTER_ACCESS_TOKEN_SECRET')
stream = ProxyStream(auth, self, async=True)

HTTPS_PROXY , , .

+1

All Articles