Reputation: 1828
I need help authenticating logging into this site using urllib. I am using python 3, but I'm willing to revert to 2.x. This is what I have sofar (basically from the documentation), it gives not errors, but its not logging in.
file =open("loggedinsource.html",'wb')
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = urllib.request.HTTPBasicAuthHandler()
auth_handler.add_password(realm='kalahari.net',uri='https://www.kalahari.net/profile/pipeline/signin.aspx?',user='myuser',passwd='mypass')
opener = urllib.request.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib.request.install_opener(opener)
f=urllib.request.urlopen('https://www.kalahari.net/profile/pipeline/signin.aspx?')
page=f.read()
file.write(page);
file.close()
I have been struggling with this for ages, any help please.
Upvotes: 0
Views: 379
Reputation: 3597
The site you are trying to log into is not using HTTP basic auth; it is using a regular HTML form.
If you want to log into something like this, you probably want to look at something like mechanize
Upvotes: 1