欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用Python的urllib庫提交WEB表單

 更新時間:2009年02月24日 02:29:03   作者:  
上次實現(xiàn)的校園網IP網關登錄器其中一個關鍵部分就是提交登錄網頁的表單,下面是我的Python實現(xiàn)代碼
復制代碼 代碼如下:

class EntryDemo( Frame ):
"""Demonstrate Entrys and Event binding"""

chosenrange = 2
url_login="http://.../ipgw/ipgw.ipgw/"
uid = '' #用戶名
password = '' # 密碼
operation = '' # 操作
range = '2' # 范圍
the_page = '' # WEB服務器返回頁面
# 表單的INPUT 值一定要記得填齊全
def login(self):
values = {
'uid' : self.uid,
'password' : self.password,
'operation' : self.operation,
'range' : self.range, # 1:國際 2:國內
'timeout':'0'
}
postdata = urllib.urlencode(values) # 表單值編碼
req = urllib2.Request(self.url_login, postdata) # 服務器請求
response = urllib2.urlopen(req)
self.the_page = response.read()

#print self.the_page

相關文章

最新評論