473,498 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Headers for Form Submision, and also HTTPrequests

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': '*****@***.***', '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

Jul 10 '06 #1
1 1568
ev*******@gmail.com wrote:
<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"/>
What happens when you add the form param "submit" with value "Login"
to the request you're doing?
Perhaps the page needs this third parameter....

--Irmen
Jul 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
24252
by: Andreas Klemt | last post by:
Hello, I get this error Message "cannot redirect after http headers have been sent" when I do this response.redirect ("home.aspx") How can I find out with vb.net if already a http header has...
22
2189
by: Platero | last post by:
Hi, I've a stupid question but... The code is the following: if(($role!='tutor')&&(array_key_exists('tutor_id',$_GET))) { $possible_ids = array(2,6,7,8,9,10); $t_id = $_GET;
1
87307
by: eldokp | last post by:
hi, In my javaScript function iam using document.ReportListForm.submit(); for form submision My ReportListForm contains <form name="RoleListForm" method="Post"...
1
2860
by: Max58kl | last post by:
Hi I am trying to setup a form that automatically sends the form values via email to a specific address. I have uploaded the script, which when I run loads a page with the following error...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.