how-to POST form data to ASP pages?

Mike Meyer mwm at mired.org
Mon Dec 26 23:56:05 EST 2005


"livin" <livin@@cox.net> writes:
> I need to post form data to an ASP page that looks like this on the page 
> itself...
> <form method='POST'><input src=\icons\devices\coffee-on.gif type='image' 
> align='absmiddle' width=16 height=16 title='Off'><input type='hidden' 
> value='Image' name='Action'><input type='hidden' value='hs.ExecX10ByName 
> "Kitchen Espresso Machine", "Off", 100'></form>
> I've been trying this but I get a syntax error...
>       params = urllib.urlencode({'hidden': 'hs.ExecX10ByName "Kitchen 
> Espresso Machine", "On", 100'})
>       urllib.urlopen("http://192.168.1.11:80/hact/kitchen.asp", params)

urlencode doesn't care about the type of the input element (or that
the page is ASP), just the name/value pairs. You want:

           params = urllib.urlencode({'Action': 'Image', ...})

The provided HTML doesn't say what the name of the second hidden input
field is. It's not at all clear what should be passed to the server in
this case.

It looks like you tried to break a string across a line boundary, but
that may be your posting  software. If you did, then that's what's
generating a syntax error, and a good indication that you should try
reading the tutorial.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list