本文整理汇总了Python中suds.transport.http.HttpTransport.open方法的典型用法代码示例。如果您正苦于以下问题:Python HttpTransport.open方法的具体用法?Python HttpTransport.open怎么用?Python HttpTransport.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类suds.transport.http.HttpTransport
的用法示例。
在下文中一共展示了HttpTransport.open方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import open [as 别名]
def open(self, request):
url = request.url
if url.startswith('file:'):
return HttpTransport.open(self, request)
else:
resp = self._session.get(url)
resp.raise_for_status()
return BytesIO(resp.content)
示例2: saxparser
# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import open [as 别名]
class Parser:
""" sax parser """
@classmethod
def saxparser(cls):
p = make_parser()
p.setFeature(feature_external_ges, 0)
h = Handler()
p.setContentHandler(h)
return (p, h)
def __init__(self, transport=None):
if transport is None:
self.transport = HttpTransport()
else:
self.transport = transport
def parse(self, file=None, url=None, string=None):
timer = metrics.Timer()
timer.start()
sax, handler = self.saxparser()
if file is not None:
sax.parse(file)
timer.stop()
metrics.log.debug('sax (%s) duration: %s', file, timer)
return handler.nodes[0]
if url is not None:
fp = self.transport.open(Request(url))
sax.parse(fp)
timer.stop()
metrics.log.debug('sax (%s) duration: %s', url, timer)
return handler.nodes[0]
if string is not None:
source = InputSource(None)
source.setByteStream(StringIO(string))
sax.parse(source)
timer.stop()
metrics.log.debug('%s\nsax duration: %s', string, timer)
return handler.nodes[0]
示例3: open
# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import open [as 别名]
def open(self, request):
self.addcredentials(request)
return HttpTransport.open(self, request)
示例4: open
# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import open [as 别名]
def open(self, request):
return HttpTransport.open(self, request)