使用urllib发http请求时:
import urllib, httplib httplib.HTTPConnection.debuglevel = 1 urllib.urlopen(http://google.com) |
使用urllib2发http请求时:
import urllib2 handler=urllib2.HTTPHandler(debuglevel=1) opener = urllib2.build_opener(handler) urllib2.install_opener(opener) request = urllib2.Request(url,headers,data) |
debuglevel设置微1可以查看header、body等内容
本文转自:http://www.cppblog.com/flyonok/archive/2010/12/16/136650.html