用Python的urllib库提交WEB表单

yipeiwu_com5年前Python基础
复制代码 代码如下:

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

相关文章

python实现将json多行数据传入到mysql中使用

将json多行数据传入到mysql中使用python实现 表需要提前创建,字符集utf8 如果不行换成utf8mb4 import json import pymysql def...

Python绘图Matplotlib之坐标轴及刻度总结

Python绘图Matplotlib之坐标轴及刻度总结

学习https://matplotlib.org/gallery/index.html 记录,描述不一定准确,具体请参考官网 Matplotlib使用总结图 import ma...

python转换摩斯密码示例

复制代码 代码如下:CODE = {'A': '.-',     'B': '-...',   'C': '-.-.',&nb...

Python3.5 Pandas模块之DataFrame用法实例分析

Python3.5 Pandas模块之DataFrame用法实例分析

本文实例讲述了Python3.5 Pandas模块之DataFrame用法。分享给大家供大家参考,具体如下: 1、DataFrame的创建 (1)通过二维数组方式创建 #!/...

ipython和python区别详解

ipython和python区别详解

ipython介绍 IPython 是一个 python 的交互式 shell,比默认的python shell 好用得多,支持变量自动补全,自动缩进,支持 bash shell命令,内...