Keep a database of (realm, uri) -> (user, password) mappings.
urllib.request/HTTPPasswordMgr
HTTPPasswordMgr