当前位置: 首页>>代码示例>>Python>>正文


Python HTTPClientFactory.protocol方法代码示例

本文整理汇总了Python中twisted.web.client.HTTPClientFactory.protocol方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPClientFactory.protocol方法的具体用法?Python HTTPClientFactory.protocol怎么用?Python HTTPClientFactory.protocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.client.HTTPClientFactory的用法示例。


在下文中一共展示了HTTPClientFactory.protocol方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _getPage

# 需要导入模块: from twisted.web.client import HTTPClientFactory [as 别名]
# 或者: from twisted.web.client.HTTPClientFactory import protocol [as 别名]
def _getPage(url, host, port):
    """
    Fetch the body of the given url via HTTP, connecting to the given host
    and port.

    @param url: The URL to GET
    @type url: C{str}
    @param host: The hostname to connect to
    @type host: C{str}
    @param port: The port number to connect to
    @type port: C{int}
    @return: A deferred; upon 200 success the body of the response is returned,
        otherwise a twisted.web.error.Error is the result.
    """
    factory = HTTPClientFactory(url)
    factory.protocol = HTTPPageGetter
    connect(GAIEndpoint(reactor, host, port), factory)
    return factory.deferred
开发者ID:nunb,项目名称:calendarserver,代码行数:20,代码来源:wiki.py

示例2: getPageU

# 需要导入模块: from twisted.web.client import HTTPClientFactory [as 别名]
# 或者: from twisted.web.client.HTTPClientFactory import protocol [as 别名]
def getPageU(url, contextFactory=None, *args, **kwargs):
    """Download a web page as a unicode object.

    Download a page. Return a deferred, which will callback with a
    page (as a string) or errback with a description of the error.

    See HTTPClientFactory to see what extra args can be passed.
    """
    scheme, host, port, path = _parse(url)
    factory = HTTPClientFactory(url, *args, **kwargs)
    factory.protocol = UnicodeHTTPPageGetter
    if scheme == 'https':
        from twisted.internet import ssl
        if contextFactory is None:
            contextFactory = ssl.ClientContextFactory()
        reactor.connectSSL(host, port, factory, contextFactory)
    else:
        reactor.connectTCP(host, port, factory)
    return factory.deferred
开发者ID:corydodt,项目名称:Goonmill,代码行数:21,代码来源:getimageurls.py


注:本文中的twisted.web.client.HTTPClientFactory.protocol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。