tags:

views:

59

answers:

2

hello everyone

i'am looking up for way to enter web site "Login"

i tried this

login_form_seq = [
      ('user', 'Lick'),
      ('pass', 'Shot'),
      ('submit', 'login')]
A=urllib.urlencode(login_form_seq)
opener = urllib2.build_opener()
try:
 site = opener.open('http://www.SMS-Example.com/user.php', A).read()
 site2 = urllib.urlopen('http://www.SMS-Example.com/sms.php').read()
 print site2
except(urllib2.URLError), msg:
 print msg
 site = ""
 pass

but actually what I should put on submit and login? i put it randomly !!

thanks...

+2  A: 

It will depend from site to site and on many site you won't even need a submit value, user/pass should be sufficient and then in many other sites they may have some hidden fields in the login form, so best way is to see the fields in the form you are submitting either directly in html or using some tool like firebug.

Other thing you must know is that logging thru one http request doesn't enable login for next http request, for that you will need to track cookies, which is not very easy but not very difficult task.

Instead you can just use twill or mechanize

Anurag Uniyal
+1, you probably need to keep track of cookies.
Denilson Sá
A: 

Really depends. Usually programmers discards value of a submit button, setting its value to something meaningful, but it isn't set in stone. In your case 'login' is the name of a button control, 'login' is its value and it will be the button's label and would be discarded with 99% probability.

eGlyph