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()

commented: thanks for the solution +1

anakastakis: Thank you for giving the rest of us the solution of your problem.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.