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. ...
随机推荐
- 要当好JavaScript程序员:5个debug技巧
我一直使用printf调试程序,一般来说都是比较顺利,但有时候,你会发现需要更好的方法.下面几个JavaScript技巧相信你一定会觉得十分有用: 1. debugger; 我以前也说过,你可以在Ja ...
- Android Intent
Intent在Android中的重要性不言而喻.本文主要总结下Intent使用过程中需要注意的一些问题. 1.隐式Intent AndroidManifest.xml声明时<intent-fil ...
- 行内js函数调用
<ul> <li onclick=abc(this);><a href="javascript:void(0);">12234588</a ...
- python3 实现简单的信用卡还款,取款转账功能V2
仅实现还款,取款,转账,信息查询功能 程序结构: atm(函数主执行程序): #Author by Andy #_*_ coding:utf-8 _*_ import os,sys Father_pa ...
- 【java项目小记--JManager】项目开始原因及github部署
--记于2016-8-11 毕业已三载,忽然想起大学时的毕业设计项目,想到曾在毕业答辩上说,会吸取老师点评并逐渐完善该项目.而今 老师点评已忘了个干净,项目也还是毕业时的样子,正好最近有些时间,打算兑 ...
- 结构struct
1.结构变量 1)定义结构类型 struct student { char *name; int age; int score[3]; }; 2)定义结构变量 struct student stu1, ...
- 初始JavaScript
本文是笔者在看廖雪峰老师的JavaScript教程时的总结 一.加载 JavaScript 1.直接在html语句中写入JavaScript语句 2.在html ...
- 声明变量,一定要用 var!
public static T TryGet<T>(Func<T> func, T ifError = default(T)) { try { return func(); } ...
- 创建用资源管理器打开FTP位置
FTP快捷方式默认用浏览器打开,而不是用资源管理器打开,管理文件不习惯. 解决方法1:创建桌面快捷方式 新建快捷方式,键入对象位置 %windir%\explorer.exe "ftp:// ...
- Minimum Depth of Binary Tree [LeetCode]
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...