python-requests Using requests behind a proxy Using proxy environment variables


Example

requests uses specific environment variables automatically for proxy detection.

  • HTTP_PROXY will define the proxy URL to use for HTTP connections
  • HTTPS_PROXY will define the proxy URL to use for HTTPS connections

Once these environment variables are set, the Python code does not need to pass anything to the proxies parameter.

requests.get('http://example.com')