python模块httplib的使用
GET:
#lianxi-httplib.HTTPConnection.request-get.py import httplib class HttpRequestGETTest(object):
def __init__(self):
#self.body='{"UserName":"Admin","Password":"693aa8d0806c532115637809a863b1a3","sessionID":""}'
self.headers = {
"Referer": '192.168.1.1',
"Accept-Encoding": "gzip, deflate,sdch",
"Connection":"Keep-Alive"} def http_get(self):
conn=httplib.HTTPConnection(host='192.168.1.1', port=80, strict=False, timeout=30)
conn.request(method='GET',url='/cgi-bin/GetLoginStatus?sessionID=undefined', body=None, headers=self.headers)
a = conn.getresponse().read()
print a lianxi=HttpRequestGETTest()
lianxi.http_get()
POST:
#lianxi-httplib.HTTPConnection.request-post.py import httplib class HttpRequestPOSTTest(object):
def __init__(self):
self.body='{"UserName":"Admin","Password":"693aa8d0806c532115637809a863b1a3","sessionID":""}'
self.headers = {
"Referer": '192.168.1.1',
"Accept-Encoding": "gzip, deflate,sdch",
"Connection":"Keep-Alive"} def http_post(self):
conn=httplib.HTTPConnection(host='192.168.1.1', port=80, strict=False, timeout=120)
conn.request(method='POST',url='/cgi-bin/Login', body=self.body, headers=self.headers)
self.session_id = conn.getresponse().read()
print self.session_id lianxi=HttpRequestPOSTTest()
lianxi.http_post()
python模块httplib的使用的更多相关文章
- python用httplib模块发送get和post请求
在python中,模拟http客户端发送get和post请求,主要用httplib模块的功能. 1.python发送GET请求 我在本地建立一个测试环境,test.php的内容就是输出一句话: 1 e ...
- Python第十三天 django 1.6 导入模板 定义数据模型 访问数据库 GET和POST方法 SimpleCMDB项目 urllib模块 urllib2模块 httplib模块 django和web服务器整合 wsgi模块 gunicorn模块
Python第十三天 django 1.6 导入模板 定义数据模型 访问数据库 GET和POST方法 SimpleCMDB项目 urllib模块 urllib2模块 ...
- python模块之httplib(在py3中功能进一步强大,请详看文档)
# -*- coding: utf-8 -*-#python 27#xiaodeng#python模块之httplib(在py3中功能进一步强大,请详看文档) import httplib#是较为底层 ...
- python模块介绍- multi-mechanize 性能测试工具
python模块介绍- multi-mechanize 性能测试工具 2013-09-13 磁针石 #承接软件自动化实施与培训等gtalk:ouyangchongwu#gmail.comqq 3739 ...
- python模块大全
python模块大全2018年01月25日 13:38:55 mcj1314bb 阅读数:3049 pymatgen multidict yarl regex gvar tifffile jupyte ...
- python urllib2 httplib HTTPConnection
httplib实现了HTTP和HTTPS的客户端协议,一般不直接使用,在python更高层的封装模块中(urllib,urllib2)使用了它的http实现. import httplib conn ...
- 使用C/C++写Python模块
最近看开源项目时学习了一下用C/C++写python模块,顺便把学习进行一下总结,废话少说直接开始: 环境:windows.python2.78.VS2010或MingW 1 创建VC工程 (1) 打 ...
- Python模块之configpraser
Python模块之configpraser 一. configpraser简介 用于处理特定格式的文件,其本质还是利用open来操作文件. 配置文件的格式: 使用"[]"内包含 ...
- Python模块之"prettytable"
Python模块之"prettytable" 摘要: Python通过prettytable模块可以将输出内容如表格方式整齐的输出.(对于用Python操作数据库会经常用到) 1. ...
随机推荐
- Oracle Deadlock / 死锁 处理
Get the directory of alert log sqlplus / as sysdba show parameters udmp SQL> show parameters dump ...
- C#: DataBase
using System.Data.SqlClient; namespace WindowsFormsApplication1{ class DB { private SqlConnection co ...
- oracle 的分析函数
row_number() over(partition by ... order by ...) rank() over(partition by ... order by ...) dense_ra ...
- android 单元测试
android studio 2.0创建一个空android moudle后, 会出现两个test目录,其中一个是Instrument Test, 另一个则是Unit Test Unit Test 和 ...
- 使用requestAnimationFrame做动画效果二
3月是个好日子,渐渐地开始忙起来了,我做事还是不够细心,加上感冒,没精神,今天差点又出事了,做过的事情还是要检查一遍才行,哎呀. 使用requestAnimationFrame做动画,我做了很久,终于 ...
- Unity3d调用iOS陀螺仪
How to write gyroscope controller with Unity3d http://blog.heyworks.com/how-to-write-gyroscope-contr ...
- [HTML/HTML5]6 使用图像
6.1 将图像作为Web页面的前景元素 使用img元素,就可以在Web页面中添加图像.img是image的缩写.只需在img元素中添加src(source的缩写)属性,并为该属性设置相应的值,就可以 ...
- c#数据绑定(5)--LINQ
嶽永鹏/文 本实例以MS AdventureWorks2008Entities数据库为基础,演示了LINQ TO ENTITY.LINQ TO ENTITYSQL和LINQ TO ENTITYCLIE ...
- LCM在Kernel中的代码分析
lcm的分析首先是mtkfb.c 1.mtk_init中platform_driver_register(&mtkfb_driver)注册平台驱动 panelmaster_init(); DB ...
- 在EC2上搭建L2TP over IPSec VPN服务器
注意(:wq保存文件 putty登陆用户名为ec2-user) 安装与配置: 环境介绍: OS:CentOS 6.4 x86_64 Minimal 1. 修改 /etc/sysctl.conf,新增如 ...