How can I set controls for a web page ??

Posted by Rami Jarrar on Stack Overflow See other posts from Stack Overflow or by Rami Jarrar
Published on 2010-03-12T16:27:54Z Indexed on 2010/03/12 16:47 UTC
Read the original article Hit count: 306

Filed under:
|

I have this login page with https, and i reach to this approach::

import ClientForm
import urllib2

request = urllib2.Request("http://ritaj.birzeit.edu")
response = urllib2.urlopen(request)
forms = ClientForms.ParseResponseEx(response)
response.close()

f = forms[0]
username = str(raw_input("Username: "))
password = str(raw_input("Password: "))

## Here What To Do

request2 = form.click()

i get the controls of that page

>>> f = forms[0]
>>> [c.name for c in f.controls]
['q', 'sitesearch', 'sa', 'domains', 'form:mode', 'form:id', '__confirmed_p', '__refreshing_p', 'return_url', 'time', 'token_id', 'hash', 'username', 'password', 'persistent_p', 'formbutton:ok']

so how can i set the username and password controls of the "non-form form" f ??? and i have another problem,, how to know if its the right username and password ??

© Stack Overflow or respective owner

Related posts about python

Related posts about webbrowser