password_mgr.add_password(None, top_level_url, 'user', 'password')
handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
opener = urllib.request.build_opener(urllib.request.HTTPHandler, handler)
request = urllib.request.Request(url)
HTTP-аутентификация в Python