views:

160

answers:

1

Hi I'm sitting in a Greyhound Bus with Wifi and want to connect a second Device to the Network. But I have to accept an onscreen contract and the device does not have a browser. To accept the contract the following form has to be accepted. The device has no CURL but all the standard python 2.6. libraries.

<form method="POST" name="wifi" id="wifi" action="http://192.168.100.1:5280/"&gt;  
  <input type="image" name="mode_login" value="Agree" src="btn_accept.gif" />  
  <input type="hidden" name="redirect" value="http://stackoverflow.com/"&gt;       
</form>

How would I write a quick python script to accept the contract?

+1  A: 

I think this should do the trick:

import urllib
data = urllib.urlencode({"mode_login":"Agree","redirect":"http://stackoverflow.com"})
result = urllib.urlopen("http://192.168.100.1:5280/",data).read()
print result
Kimvais
There seems to be a small problem with the syntax and I can't try it now but I think it can work. Providing the data argument should start a POST request.
Janusz
Ah, there was a " missing
Kimvais