handler = urllib.request.HTTPHandler(debuglevel=1)
opener = urllib.request.build_opener(handler)
urllib.request.install_opener(opener)
How to debug urllib2 request that uses a basic authentication handler