當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。