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


Python UserAgentBase.open方法代碼示例

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


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

示例1: _mech_open

# 需要導入模塊: from _useragent import UserAgentBase [as 別名]
# 或者: from _useragent.UserAgentBase import open [as 別名]
    def _mech_open(self, url, data=None, update_history=True, visit=None,
                   timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT):
        try:
            url.get_full_url
        except AttributeError:
            # string URL -- convert to absolute URL if required
            scheme, authority = _rfc3986.urlsplit(url)[:2]
            if scheme is None:
                # relative URL
                if self._response is None:
                    raise BrowserStateError(
                        "can't fetch relative reference: "
                        "not viewing any document")
                url = _rfc3986.urljoin(self._response.geturl(), url)

        request = self._request(url, data, visit, timeout)
        visit = request.visit
        if visit is None:
            visit = True

        if visit:
            self._visit_request(request, update_history)

        success = True
        try:
            response = UserAgentBase.open(self, request, data)
        except urllib2.HTTPError, error:
            success = False
            if error.fp is None:  # not a response
                raise
            response = error
開發者ID:BayshoreNetworks,項目名稱:l7secassay,代碼行數:33,代碼來源:_mechanize.py


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