httplib
可爆破目录
import httplib
import urllib def sendhttp():
data = urllib.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'})
headers = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
conn = httplib.HTTPConnection('www.swpu.edu.cn')
#conn = httplib.HTTPConnection('www.swpu.edu.cn')
conn.request('POST','/',data,headers)
httpres = conn.getresponse()
print httpres.status
print httpres.reason
print len(httpres.read())
conn.close()
if __name__ == "__main__":
sendhttp()
#coding=gbk
import httplib
conn = httplib.HTTPConnection("www.google.cn")
conn.request('get', '/')
print conn.getresponse().read()
conn.close()
httplib.HTTPConnection ( host , port , strict , timeout )
参数strict的 默认值为false, 表示在无法解析服务器返回的状态行时( status line) (比较典型的状态行如: HTTP/1.0 200 OK ),是否抛BadStatusLine 异常;可选参数timeout 表示超时时间
HTTPConnection.request ( method , url , body , headers )
调用request 方法会向服务器发送一次请求,method 表示请求的方法,常用有方法有get 和post和head ;url 表示请求的资源的url ;body 表示提交到服务器的数据,必须是字符串(如果method 是"post" ,则可以把body 理解为html 表单中的数据);headers 表示请求的http 头。
HTTPConnection.getresponse ()
获取Http 响应。返回的对象是HTTPResponse 的实例。
连接到Http 服务器。
HTTPConnection.connect ()
关闭与服务器的连接。
HTTPConnection.close ()
HTTPConnection.set_debuglevel ( level )
设置高度的级别。参数level 的默认值为0 ,表示不输出任何调试信息。
httplib.HTTPResponse
HTTPResponse表示服务器对客户端请求的响应。往往通过调用HTTPConnection.getresponse()来创建,它有如下方法和属性:
HTTPResponse.read([amt])
获取响应的消息体。如果请求的是一个普通的网页,那么该方法返回的是页面的html。可选参数amt表示从响应流中读取指定字节的数据。
HTTPResponse.getheader(name[, default])
获取响应头。Name表示头域(header field)名,可选参数default在头域名不存在的情况下作为默认值返回。
HTTPResponse.getheaders()
以列表的形式返回所有的头信息。
HTTPResponse.msg
获取所有的响应头信息。
HTTPResponse.version
获取服务器所使用的http协议版本。11表示http/1.1;10表示http/1.0。
HTTPResponse.status
获取响应的状态码。如:200表示请求成功。
HTTPResponse.reason
返回服务器处理请求的结果说明。一般为”OK”
#coding=gbk
import httplib
conn = httplib.HTTPConnection("www.g.cn", 80, False,5)
conn.request('get', '/', headers = {"Host": "www.google.cn",
"User-Agent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1) Gecko/20090624 Firefox/3.5",
"Accept": "text/plain"})
res = conn.getresponse()
print 'version:', res.version
print 'reason:', res.reason
print 'status:', res.status
print 'msg:', res.msg
print 'headers:', res.getheaders()
conn.close()
httplib的更多相关文章
- python httplib get和post获取数据
httplib 下的 status http请求的状态 200 404 500... reason 返回答复 OK或者 FAULRE read() 读取内容 get方法: #!/usr/bin/e ...
- 开源代码:Http请求封装类库HttpLib介绍、使用说明
今天介绍一个很好用的Http请求类库--Httplib.一直以来,我们都是为了一次web请求,单独写一段代码 有了这个类,我们就可以很方便的直接使用了. 项目介绍: http://www.suchso ...
- C#的HTTP开发包 HttpLib
HttpLib 可以用来简化在 C# 应用中异步的访问 Web 服务的操作.同时包含文件上传和访问网页的方法. 支持: GET POST Form Encoded Multipart File Upl ...
- Python爬虫学习(2): httplib
httplib模块实现了HTTP和HTTPS的客户端部分,但是一般不直接使用,经常通过urllib来进行HTTP,HTTPS的相关操作. 如果需要查看其源代码可以通过查找命令定位: find / -n ...
- httplib用法
httplib的内容上是很多,也比较简单.以下是一个非常简单的例子,使用httplib获取google首页的html: import httplib conn = httplib.HTTPConnec ...
- python模块httplib的使用
GET: #lianxi-httplib.HTTPConnection.request-get.py import httplib class HttpRequestGETTest(object): ...
- HttpLib - 一个对 Http 协议进行封装的库
今日,在 Codeplex 上看到一个开源项目,对 Http 协议进行了封装,这下可以方便这些在 .NET 平台下访问 Web 服务器的同学们了,比如,从 Web 服务器抓取一个页面,使用 .NET ...
- python2 httplib 笔记
python2 httplib 笔记 #coding=utf-8 ''' Created on 2014年9月25日 @author: cocoajin ''' import httplib,url ...
- python中urllib, urllib2,urllib3, httplib,httplib2, request的区别
permike原文python中urllib, urllib2,urllib3, httplib,httplib2, request的区别 若只使用python3.X, 下面可以不看了, 记住有个ur ...
随机推荐
- hdu 2098
ps:TLE一次....因为判断素数的时候没开方...作死.. 代码: #include "stdio.h" #include "math.h" int inp ...
- 【LeetCode OJ】Interleaving String
Problem Link: http://oj.leetcode.com/problems/interleaving-string/ Given s1, s2, s3, find whether s3 ...
- Functions
Small The first rule of functions is that they should be small.The second rule of functions is that ...
- 快速实现Magento多语言的设置和产品数据的多语言方法
MagenTo默认支持多语言网店,不过要使用多语言功能,需要进行一些设置. 一.后台多语言支持(中文化) Magento登录后台时默认的是显示的是英文界面,在页面左下角选择语言为中文就会跳转为中文界面 ...
- Magento Soap Api接口出错无法使用
在给客户测试Magento Soap接口的时候出现如下错误提示. This page contains the following errors:error on line 3 at column 6 ...
- C语言Makefile文件使用
C语言中代码Makefile文件的写法 单文件,例: #定义变量 CFLAGS=gcc #具体命令都需要一个入口,all: 这个就相当于入口,默认情况,执行第一次入口, #后面执行其他入口进行依赖,如 ...
- JDBC接口规范
前言 JDBC(JavaDatabase Connectivity)表示Java查询引擎连接,由一组用Java编程语言编写的类和接口组成.JDBC为Java程序访问关系型查询引擎提供了编程接口,为查询 ...
- lanuchy快捷操作
down arrow: display history shift+delete: remove the item from the distory
- 修改数据库mysql字符编码为UTF8
Mysql数据库是一个开源的数据库,应用非常广泛.以下是修改mysql数据库的字符编码的操作过程. 步骤1:查看当前的字符编码方法 mysql> show variables like'char ...
- 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it. 代码如下: /** * Definition for singly-linked lis ...