您的位置:首页 > 编程语言 > Python开发

python访问的时候,将debug信息打印出来

2014-07-30 23:24 393 查看
import urllib2
httpHandler = urllib2.HTTPHandler(debuglevel=1)
httpsHandler = urllib2.HTTPSHandler(debuglevel=1)
opener = urllib2.build_opener(httpHandler, httpsHandler)
urllib2.install_opener(opener)
response = urllib2.urlopen('http://www.baidu.com')
print 'a'
print response.read()


免得抓包 在打印台都打印出来 请求,相应信息打印出来

send: 'GET / HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: www.baidu.com\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n'

reply: 'HTTP/1.1 200 OK\r\n'

header: Date: Wed, 30 Jul 2014 15:06:10 GMT

header: Content-Type: text/html; charset=utf-8

header: Transfer-Encoding: chunked

header: Connection: Close

header: Vary: Accept-Encoding

header: Set-Cookie: BAIDUID=6C110EA08744D95D4FFDAA6EAB5B87C8:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com

header: Set-Cookie: BDSVRTM=0; path=/

header: P3P: CP=" OTI DSP COR IVA OUR IND COM "

header: Cache-Control: private

header: Cxy_all: baidu+38e329b0efa4e62de8845f9602ba55f8

header: Expires: Wed, 30 Jul 2014 15:05:22 GMT

header: X-Powered-By: HPHP

header: Server: BWS/1.1

header: BDPAGETYPE: 1

header: BDQID: 0xe3822dd3000081dc

header: BDUSERID: 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐