how-to POST form data to ASP pages?

livin livin at
Sun Jan 1 15:46:25 EST 2006


The library is the PC version of 2.3  --- I have done some more testing.

I simplified my .py to only 2 lines...

import urllib
urllib.urlopen('http://192.168.1.11', urllib.urlencode({'control_device': 
'Kitchen Lights=off'}))

I get this error...

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 564, in send
File "Q:\python\python23.zlib\httplib.py", line 548, in connect
IOError
:
[Errno socket error] (10060, 'Operation timed out')

I've taken the commands I'm using from working HTTP & ASP pages.

Here's actual code from an HTML page I'm using for the same device I'm 
trying in my .PY...

<form method="post">
<td nowrap class="tableroweven">
<a name="bm83274"></a>
<input type="hidden" name="bookmark" value="83274">
<input type="hidden" name="ref_page" value="stat">
<input type="hidden" name="control_device" value="Kitchen Lights">
<input class="formbutton" type="submit" name="action_on" value="On">
<input class="formbutton" type="submit" name="action_off" value="Off">
<select class="formdropdown" name="selectdim" SIZE="1" 
onchange="SubmitForm(this)">
<option selected value="0">0%</option>
<option value="10">10%</option>
<option value="20">20%</option>
<option value="30">30%</option>
<option value="40">40%</option>
<option value="50">50%</option>
<option value="60">60%</option>
<option value="70">70%</option>
<option value="80">80%</option>
<option value="90">90%</option>
<option value="100">100%</option>
</select>
</td></form>




"Alan Kennedy" <alanmk at hotmail.com> wrote in message 
news:E4Xtf.3968$j7.88027 at news.indigo.ie...
> [livin]
>> I have tried the code you suggested and .. .. 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')
>
> OK, now we're getting somewhere.
>
> As you can probably guess from the error message, the socket through which 
> urllib is making the request is not connected to the server. We have to 
> figure out why.
>
> That library path is unusual: Q:\python\python23.zlib\httplib.py
>
> Python supports reading library modules from a zip file, but the standard 
> installations generally don't use it, except for Python CE, i.e. Python 
> for Microsoft Windows PocketPC/CE/WTF. Is this the platform that you're 
> using? If I remember rightly, Python for Pocket Windows doesn't support 
> sockets, meaning that urllib wouldn't work on that platform.
>
> Another thing to establish is whether the URL is working correctly, from a 
> client you know works independently from your script above, e.g. an 
> ordinary browser. When you submit to your form handling script from an 
> ordinary browser, does it work?
>
> -- 
> alan kennedy
> ------------------------------------------------------
> email alan:              http://xhaus.com/contact/alan 





More information about the Python-list mailing list