encoded_params = urllib.parse.urlencode(params)
with contextlib.closing(opener.open(login_url, encoded_params)) as f:
    html = f.read()
print(html)
How do I authenticate a urllib2 script in order to access HTTPS web services from a Django site?