Skip to content

Instantly share code, notes, and snippets.

@BrunoCaimar
Created April 15, 2016 17:54
Show Gist options
  • Save BrunoCaimar/cdb960f1ed0b6cb1d398c84337b4dda9 to your computer and use it in GitHub Desktop.
Save BrunoCaimar/cdb960f1ed0b6cb1d398c84337b4dda9 to your computer and use it in GitHub Desktop.
Python - Set Proxy via Environment Variables
def set_proxy_environment_variables():
proxies = urllib.getproxies()
http_proxy = proxies.get('http')
https_proxy = proxies.get('https')
Utils.logs("Proxies: {0}".format(proxies))
if http_proxy is not None and http_proxy != "":
Utils.logs("Configurando http proxy: {0}".format(http_proxy))
os.environ["HTTP_PROXY"] = http_proxy
if https_proxy is not None and https_proxy != "":
Utils.logs("Configurando https proxy: {0}".format(https_proxy))
os.environ["HTTPS_PROXY"] = https_proxy
@olivierRoche
Copy link

module 'urllib' has no attribute 'getproxies'

@JnsLns
Copy link

JnsLns commented Jan 24, 2021

It must be
urllib.request.getproxies()

module 'urllib' has no attribute 'getproxies'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment