0

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?

aelbouha
  • 11
  • 2
  • Does this answer your question? [How to pass all Python's traffics through a http proxy?](https://stackoverflow.com/questions/31639742/how-to-pass-all-pythons-traffics-through-a-http-proxy) – Christoph H. Mar 22 '23 at 13:05

2 Answers2

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
  • 1
    Thanks 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