Question about urllib and posting to an external script

evanpmeth at gmail.com evanpmeth at gmail.com
Tue Sep 5 22:39:45 EDT 2006


I have tried multiple ways of posting information to a website and have
failed. I have seen this problem on other forums can someone explain or
point me to information on how POST works through urllib an different
broweser (what is the difference).

my first attempt was out of the docs:

Code:

import httplib, urllib params = urllib.urlencode({'email' : 'a at a.com',
'password' : 'pass'}) h = httplib.HTTP("login.myspace.com:80")
h.putrequest("POST", "/index.cfm?fuseaction=login.process&amp")
h.putheader("User-Agent", "Mozilla/5.0 <Windows; U; Windows NT 5.1;
en-US; rv;1.8.0.6> Gecko/20060728 Firefox/1.5.0.6")
h.putheader("Content-length", "%d" % len(params)) h.putheader('Accept',
'text/plain') 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 returned a page denying access
and then tried:

Code:

import httplib, urllib params = urllib.urlencode({'email' :
'ezikz at bonbon.net', 'password' : 'dicksuck'})
data
=urllib.urlopen("http://login.myspace.com/index.cfm?fuseaction=login.process&amp:80",
params).read()
print data



This returned a page that asked me if i wanted to sign up, which
confused me even more.

all i want to do is post this form:
HTML Code:

<form method='POST' enctype='multipart/form-data'
action='http://login.myspace.com/index.cfm?fuseaction=login.process&amp'>
<input type="text" name="email" > <input type="password"
name="password" > <input type="submit" value="Login"/>



Please help i was thinking maybe the site did browser sniffing and only
allowed certain types of browsers. I dont know. I have seen this
problem on other forums can someone explain or point me to information
on how POST works through urllib an different broweser (what is the
difference).




More information about the Python-list mailing list