help with logging into a asp page using urllib
I'm trying to login to a aspx page. this is what i have so far:
o = urllib2.build_opener(urlli开发者_开发问答b2.HTTPCookieProcessor())
urllib2.install_opener(o)
page = 'http://page/LoginForm.aspx'
raw_params = {'ctl00$ContentPlaceHolder1$usertext':'username','ctl00$ContentPlaceHolder1$passtext':'password', 'ctl00$ContentPlaceHolder1$IUlogin':'Login'}
params = urllib.urlencode(raw_params)
f = o.open(page,params)
f = o.open('http://page/upload.aspx') #you cant access this unless you're logged in
however, this does not work i get a server error 500(because it did not get logged in). I can login fine with mechanize...
Well asp.net is problematic by itself in many ways. I can only imagine how the page is coded, but mostly asp.net submits are done in a very painful way through _doPostback where it sets additional hidden fields. You might want to try reading this http://www.xefteri.com/articles/show.cfm?id=18 and reviewing the generated html of the page
精彩评论