Hi,
 
You can try this:
 
import httplib, urllib
params = urllib.urlencode({'ID':'1','Name':'name', 'Eid':'we[at]you.com'})
#Assumed URL: test.com/cgi-bin/myform
h = httplib.HTTP("test.com")
h.putrequest("POST", "/cgi-bin/myform")
h.putheader("Content-length", "%d" % len(params))
h.putheader('Accept', 'text/plain')
h.putheader('Host', 'test.com')
h.endheaders()
h.send(params)
reply, msg, hdrs = h.getreply()
print reply # should be 200 in case of reply
data = "" # get the raw HTML
f = open('test.html','w') # put response in the html form
f.write(data)
f.close()
 
Hope it will solve your problem.
 
Regards,
Nav
---
 
We on Orkut.com!!!
 
The Revolutions (Comp Sci RnD)
www.orkut.com/Community.aspx?cmm=13263692-
 
Jobs by Employee Reference
www.orkut.com/Community.aspx?cmm=19517702
 
 

Kent Johnson <[EMAIL PROTECTED]> wrote:
Patricia wrote:
> Hi,
>
> I have used urllib and urllib2 to post data like the following:
>
> dict = {}
> dict['data'] = info
> dict['system'] = aname
>
> data = "">> req = urllib2.Request(url)
>
> And to get the data, I emulated a web page with a submit button:
> s = ""
> s += " "
> s += ""
> s += ""
> s += ""
> s += ""
>
>
> I would like to know how to send a file. It's a text file that will be
> gzipped before being posted. I'm using python version 2.2.3.

There are some old examples hereA
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306

I think the modern way uses email.MIMEMultipart but I don't have an
example handy.

Kent

_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to