import urllib.request proxy_support = urllib.request.ProxyHandler({'https': '127.0.0.1:8080', 'http': '127.0.0.1:8080'}) opener = urllib.request.build_opener(proxy_support) urllib.request.install_opener(opener) url = 'http://python.org' print(urllib.request.urlopen(url))