當前位置: 首頁>>代碼示例>>Python>>正文


Python UserAgentBase.__init__方法代碼示例

本文整理匯總了Python中_useragent.UserAgentBase.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python UserAgentBase.__init__方法的具體用法?Python UserAgentBase.__init__怎麽用?Python UserAgentBase.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在_useragent.UserAgentBase的用法示例。


在下文中一共展示了UserAgentBase.__init__方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from _useragent import UserAgentBase [as 別名]
# 或者: from _useragent.UserAgentBase import __init__ [as 別名]
    def __init__(self,
                 factory=None,
                 history=None,
                 request_class=None,
                 ):
        """

        Only named arguments should be passed to this constructor.

        factory: object implementing the mechanize.Factory interface.
        history: object implementing the mechanize.History interface.  Note
         this interface is still experimental and may change in future.
        request_class: Request class to use.  Defaults to mechanize.Request
         by default for Pythons older than 2.4, urllib2.Request otherwise.

        The Factory and History objects passed in are 'owned' by the Browser,
        so they should not be shared across Browsers.  In particular,
        factory.set_response() should not be called except by the owning
        Browser itself.

        Note that the supplied factory's request_class is overridden by this
        constructor, to ensure only one Request class is used.

        """
        self._handle_referer = True

        if history is None:
            history = History()
        self._history = history

        if request_class is None:
            if not hasattr(urllib2.Request, "add_unredirected_header"):
                request_class = _request.Request
            else:
                request_class = urllib2.Request  # Python >= 2.4

        if factory is None:
            factory = DefaultFactory()
        factory.set_request_class(request_class)
        self._factory = factory
        self.request_class = request_class

        self.request = None
        self._set_response(None, False)

        # do this last to avoid __getattr__ problems
        UserAgentBase.__init__(self)
開發者ID:AaronFae,項目名稱:VimProject,代碼行數:49,代碼來源:_mechanize.py


注:本文中的_useragent.UserAgentBase.__init__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。