Search code examples
pythonproxyredditpraw

Is it possible to use Reddit API through proxy?


I want to use API through proxy in PRAW but I have no idea how to do it.. Any help?

I read through https://praw.readthedocs.io/en/stable/getting_started/configuration.html#using-an-http-or-https-proxy-with-praw

..and as I understand.. if I want to use the API through a proxy I must set it before running the script in the command line?

Isn't there a possibility to set the proxy in the Python code itself before authorizing through password flow?


Solution

  • It seems the solution inside the code is:

    os.environ["HTTP_PROXY"] = "http://proxy.host.com:8080"
    
    print("Request page with IP:", requests.get("http://icanhazip.com", timeout=1.5).text.strip())