exclusion_list = ['http://www.google.com/', 'http://localhost/']
no_proxy = urllib.request.ProxyHandler({})
no_proxy_opener = urllib.request.build_opener(no_proxy)
default_proxy_opener = urllib.request.build_opener()
url = 'http://www.example.com/'
if url in exclusion_list:
    opener = no_proxy_opener
else:
    opener = default_proxy_opener
page = opener.open(url)
print(page)
How can I apply authenticated proxy exceptions to an opener using urllib2?