Search code examples
pythonproxytweepytwitterapi-python

Use proxy with Tweepy


I want to use proxy (with/without auth) with Twitter API via Tweepy in Python Reading the documentation I tried something (I think really wrong) like this:

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth, proxy='1.2.3.4:1234')

But obviously didn't work


Solution

  • Since Tweepy doesn't seems to support proxy, you can change the ones on your system changing the https_proxy variable

    On Linux:

    export HTTPS_PROXY="http://xxxx:8888"
    

    On Windows:

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

    You can do it before launching the script or inside it, using subprocess to run a command