Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

submitting webforms python

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()
like image 460
Vort3x Avatar asked Jun 07 '26 12:06

Vort3x


1 Answers

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.

like image 175
Lennart Regebro Avatar answered Jun 09 '26 04:06

Lennart Regebro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!