import urllib2manager = urllib2.HTTPPasswordMgrWithDefaultRealm()manager.add_password(None, 'https://app.streamsend.com/emails', 'login', 'key')handler = urllib2.HTTPBasicAuthHandler(manager)director = urllib2.OpenerDirector()director.add_handler(handler)req = urllib2.Request('https://app.streamsend.com/emails', headers = {'Accept' : 'application/xml'})result = director.open(req)# result.read() will contain the data# result.info() will contain the HTTP headers# To get say the content-length headerlength = result.info()['Content-Length']
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)