python提交web表单_用Python的urllib库提交WEB表单

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

原文:http://www.jb51.net/article/17318.htm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值