Hello, I'm trying to make a web bot that fills out a login form from this at&t site
http://www.viewmymessage.com/en/legacy/login.jsp

I cannot seem to get it to work though here is my code:

import urllib
import urllib2

url = 'http://www.viewmymessage.com/en/legacy/login.jsp'

user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'

values = {'messageId' : 'i1stbnan7','password' : 'tax3akin'}
headers = { 'User-Agent' : user_agent }

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
print response.read()

I figured it out by using a library called clientform. Incase anyone else has this problem heres the working code:

from urllib2 import urlopen
from ClientForm import ParseResponse

response = urlopen("http://www.viewmymessage.com/en/legacy/login.jsp")
forms = ParseResponse(response, backwards_compat=False)
form = forms[0]
print form

original_text = form["messageId"]
form["messageId"] = "i1stbnan7"

original_text = form["password"]
form["password"] = "tax3akin"


print urlopen(form.click()).read()

Comments
thanks for the solution

I tried working with your example its works good
extending further, when my first page opens which is a javascript
there is a hyperlink which activates a control
when i used the click on the hyperlink it says that is not clickable(may be cause its not a button)
how do i have to activate the link, using the click event

This question has already been answered. Start a new discussion instead.