如何在Python中执行Post请求?

2024-09-25 00:22:50 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我坐在一辆带Wifi的灰狗巴士上,想把第二台设备连接到网络上。但我必须接受屏幕上的合同,而且设备没有浏览器。 要接受合同,必须接受以下格式。这个设备没有CURL,只有标准的python2.6。图书馆。在

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

如何编写一个快速的python脚本来接受合同?在


Tags: name网络formhttpinput标准屏幕value
1条回答
网友
1楼 · 发布于 2024-09-25 00:22:50

我认为这应该能起到作用:

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

相关问题 更多 >