I am currently working a program that was intended to be purely JS and AJAX. Due to the cross domain access problems i have defaulted to a language I enjoy more, Python. My project consists of a web service that provides information from a site that can only be accessed through a portal type system. The information is retrieved by a python script then relayed to the web browser. This information is behind a simple username and password type setup. The reason I am requesting help is because I am currently in a ditch. The form submission part is very simple in python and I have used it before. I never used it for logging into a site though. This is where I ran into problems, I try to submit a user name and password that I know are correct, but it does not work. My only guess is that the headers, are incorrect and the site i am trying to access has a security measure that prevents form submission from anything other than a web browser. I tried multiple combinations referring to the docs, but nothing seemed to work. It would submit but return: "Invalid login", so it was posting to the site but probaly posting the incorrect values. Here is a cut down version in html that works just fine through a web browser for logining into the site:
<form action="http://login.myspace.com/index.cfm?fuseaction=login.process" method="post" name="theForm" id="theForm"> <input type="text" name="email" > <input type="password" name="password" > <input type="submit" value="Login"/> And here is a stand alone version from python docs of the form submision through python: import httplib, urllib params = urllib.urlencode({'email': '[EMAIL PROTECTED]', 'password': '*****'}) h = httplib.HTTP("login.myspace.com:80") h.putrequest("POST", "/index.cfm?fuseaction=login.process") h.putheader("Content-length", "%d" % len(params)) h.putheader('Accept', 'text/plain') h.putheader('Host', 'www.myspace.com') h.endheaders() h.send(params) reply, msg, hdrs = h.getreply() print reply # should be 200 data = h.getfile().read() # get the raw HTML print data This code returns an invalid login even though the values are correct. The only thing i can think of that there is something wrong with the headers. Is there anyway to imitate a web browser if that is the problem or some how figure out what the headers consist of that are being submited and just copy that? and also is it possible once you are logged in to this website to continue to a different page within the member area, to extract more information? If anyone has any sugestions on another way to go about doing this please let me know, and also i already thought about using a mozilla/firefox plugin but i want to do it in python :). -EvanPMeth -- http://mail.python.org/mailman/listinfo/python-list