how-to POST form data to ASP pages?

livin livin at
Wed Dec 28 05:40:07 CET 2005


Mike,
I appreciate the help... I'm a noobie to Python. I know vbscript & jscript 
but nothing else.

I obviously do not need to submit the images

my code looks like this but it is not working... any ideas?


      params = urllib.urlencode({'action': 'hs.ExecX10ByName "Kitchen 
Espresso Machine", "Off", 100'})
      urllib.urlopen("http://192.168.1.11:80/hact/kitchen.asp", params)



"Mike Meyer" <mwm at mired.org> wrote in message 
news:861wzzdtp6.fsf at bhuda.mired.org...
> "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