http POSTing
Stephen J King
king at calibre-dd.com
Wed Jan 5 14:16:22 EST 2000
Jeff Kunce wrote:
>
> > i'm trying to create an offline form i can send to a website
> > through "POST". being new to python and minimal knowledge of
>
> For a simple example, see
> urlpost.py
> at
> http://starship.python.net/crew/jjkunce/
A very nice example, but perhaps not as simple as it might be?
The requirement is stated:
<FORM ACTION="http://www.test.com/form.html" METHOD="POST">
<INPUT TYPE="hidden" NAME="hidd" VAL="en">
<INPUT TYPE="text" NAME="email" VALUE="you at yourmail.com">
<INPUT TYPE="image" SRC=post.gif NAME="POST">
</FORM>
Although I don't know if you can post to an html page ...
Here's what I threw together:
#!/usr/local/bin/python
from socket import *
msg = 'hidd=en&email=you at yourmail.com'
ns = socket(AF_INET, SOCK_STREAM)
ns.connect('www.test.com', 80)
ns.send('POST /form.html HTTP/1.0\n')
ns.send('Accept: text/plain\n')
ns.send('Accept: text/html\n')
ns.send('User-Agent: stimpy\n')
ns.send('Content-type: application/x-www-form-urlencoded\n')
ns.send('Content-length: %d\n' % len(msg))
ns.send('\n')
ns.send(msg)
while 1:
answer = ns.recv(1024)
if not answer:
break
print answer,
ns.close()
# end
Assuming that you have the tkinter form you mention.
-- Stephen J King Technology Manager Calibre Digital Pictures
-- king at calibre-dd.com http://www.calibredigital.com
More information about the Python-list
mailing list