I am looking to use a public API running on a distant server from within my company. For security reasons, I am supposed to redirect all the traffic via the company's PROXY. Does anyone know how to do this in Python?
            Asked
            
        
        
            Active
            
        
            Viewed 1,241 times
        
    2 Answers
2
            
            
        Directly in python you can do :
os.environ["HTTP_PROXY"] = http://proxy.host.com:8080.
Or as it has been mentioned before launching by @hardillb on a terminal :
export HTTP_PROXY=http://proxy.host.com:8080
        Simon Delecourt
        
- 1,519
 - 8
 - 13
 
- 
                    1Thanks man, I searched for this for hours :D although it should be: os.environ["HTTP_PROXY"] = "http://proxy.host.com:8080" with quotes around the proxy – Allar Feb 25 '22 at 01:11
 - 
                    if i have to assign multiple address to no_proxy will it be like: os.environ["no_proxy"] = "add1","add2","localhost","127.0.0.1" I m not sure if this is correct – Shikhar Gupta Apr 25 '22 at 06:41
 
1
            
            
        Set the HTTP_PROXY environment variable before starting your python script
e.g. export HTTP_PROXY=http://proxy.host.com:8080
        hardillb
        
- 54,545
 - 11
 - 67
 - 105