Reputation: 1828
I am trying to submit this webform and log into this site: https://www.kalahari.net/profile/pipeline/signin.aspx
I keep getting the login site's source code as output when the script is done,so it seems like all is working (no errors) but it's just not logging in. I can't find what I am doing wrong.Please help. I am using Python 3.1.2, I can't use Mechanize as the code needs to be written in Python 3.x
I think my problem might be the POST url I am posting the login information to, but I cant seem to figure it out, and what it should be.
f=open("page_src.html",'wb')
cj=cookiejar.CookieJar()
params=urllib.parse.urlencode({'ctl00$ctl00$cplhMain$cplhContent$txtEmail': 'username', 'ctl00$ctl00$cplhMain$cplhContent$txtPassword': 'pass'})
opener = req.build_opener(req.HTTPCookieProcessor(cj))
opener = urllib.request.FancyURLopener()
page = opener.open("https://www.kalahari.net/profile/pipeline/signin.aspx", params)
profilepage = opener.open("https://www.kalahari.net/profile/pipeline/profile.aspx")
source=profilepage.read()
f.write(source)
f.close()
Upvotes: 3
Views: 319
Reputation: 172367
The site is probably using cookies for the login, so you must too. That means you must save the cookies you get when you log in and send them to the site with each following request.
Check out http.cookiejar.
Upvotes: 1