加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

用Python的urllib库提交WEB表单

发布时间:2020-05-24 09:48:29 所属栏目:Python 来源:互联网
导读:复制代码代码如下:classEntryDemo(Frame):"""DemonstrateEntrysandEventbinding"""chosenrange=2url_login="http://.../ipgw/ipgw.ipgw/"uid=''#用户名password=''#密码operation=''#操作range='2'

复制代码 代码如下:
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

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读