handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
opener = urllib.request.build_opener(urllib.request.HTTPHandler, handler)
request = urllib.request.Request(url)
HTTP Authentication in Python