A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/080151.html below:

using python to post to a HTML form

using python to post to a HTML formdsavitsk dsavitsk at e-coli.net
Wed Apr 4 17:57:01 EDT 2001
"Jeremy Lamplough" <jeremy.lamplough at motorola.com> wrote in message
news:9afn54$fd3$1 at newshost.mot.com...
> Hi,
>
> I'm sure this isn't too hard, but haven't I haven't seen it done.  I need
a
> script that will input values to a HTML form, then submit the form and
grab
> the returned HTML.
>
> Any (pseudo) code would be great.
>
> Thanks,
>
> jeremy
>
>

from the python docs ...

>>> import httplib, urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> h = httplib.HTTP("www.musi-cal.com:80")
>>> h.putrequest("POST", "/cgi-bin/query")
>>> h.putheader("Content-length", "%d" % len(params))
>>> h.putheader('Accept', 'text/plain')
>>> h.putheader('Host', 'www.musi-cal.com')
>>> h.endheaders()
>>> h.send(params)
>>> reply, msg, hdrs = h.getreply()
>>> print reply # should be 200
>>> data = h.getfile().read() # get the raw HTML



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4