how-to POST form data to ASP pages?
livin
livin at
Sun Jan 1 14:35:06 EST 2006
Hi Alan,
I have tried the code you suggested and a more simple set of post parameters
(below).
import urllib
name_value_pairs = {'control_device': 'Kitchen Lights=off'}
params = urllib.urlencode(name_value_pairs)
urllib.urlopen("http://192.168.1.11:80", params)
Either way I get this error log...
File "Q:\python\python23.zlib\urllib.py", line 78, in urlopen
File "Q:\python\python23.zlib\urllib.py", line 183, in open
File "Q:\python\python23.zlib\urllib.py", line 297, in open_http
File "Q:\python\python23.zlib\httplib.py", line 712, in endheaders
File "Q:\python\python23.zlib\httplib.py", line 597, in _send_output
File "Q:\python\python23.zlib\httplib.py", line 576, in send
File "<string>", line 1, in sendall
IOError
:
[Errno socket error] (10057, 'Socket is not connected')
"Alan Kennedy" <alanmk at hotmail.com> wrote in message
news:9bUtf.3962$j7.88355 at news.indigo.ie...
> [livin]
>> I'm not a coder really at all (I dabble with vbscript & jscript) but an
>> asking for help to get this working.
>>
>> I have tried this...
>>
>> params = urllib.urlencode({'action': 'hs.ExecX10ByName "Kitchen
>> Espresso Machine", "On", 100'})
>> urllib.urlopen("http://192.168.1.11:80/hact/kitchen.asp", params)
>
> You should try to phrase your question so that it is easier for us to
> understand what is going wrong, and thus help you to correct it.
>
> As Mike already suggested, you have a string that may be spread over two
> lines, which would be illegal python syntax, and which would give a
> SyntaxError if run. You should be sure that this is not the cause of your
> problem before going further.
>
> The following code should do the same as the above, but not suffer from
> the line breaks problem.
>
> name_value_pairs = {
> 'action': 'hs.ExecX10ByName "Kitchen Espresso Machine", "On", 100'
> }
> params = urllib.urlencode(name_value_pairs)
> urllib.urlopen("http://192.168.1.11:80/hact/kitchen.asp", params)
>
> BTW, it looks to me like you may be opening up a security hole in your
> application. The following string looks very like a VB function
> invocation: 'hs.ExecX10ByName "Kitchen Espresso Machine", "On", 100'
>
> Are you executing the contents of form input fields as program code?
> That's highly inadvisable from a security point of view.
>
> Happy New Year.
>
> --
> alan kennedy
> ------------------------------------------------------
> email alan: http://xhaus.com/contact/alan
More information about the Python-list
mailing list