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


Python request.selector方法代码示例

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


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

示例1: retry_proxy_http_basic_auth

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def retry_proxy_http_basic_auth(self, url, realm, data=None):
        host, selector = splithost(url)
        newurl = 'http://' + host + selector
        proxy = self.proxies['http']
        urltype, proxyhost = splittype(proxy)
        proxyhost, proxyselector = splithost(proxyhost)
        i = proxyhost.find('@') + 1
        proxyhost = proxyhost[i:]
        user, passwd = self.get_user_passwd(proxyhost, realm, i)
        if not (user or passwd): return None
        proxyhost = "%s:%s@%s" % (quote(user, safe=''),
                                  quote(passwd, safe=''), proxyhost)
        self.proxies['http'] = 'http://' + proxyhost + proxyselector
        if data is None:
            return self.open(newurl)
        else:
            return self.open(newurl, data) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:19,代码来源:request.py

示例2: retry_proxy_https_basic_auth

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def retry_proxy_https_basic_auth(self, url, realm, data=None):
        host, selector = splithost(url)
        newurl = 'https://' + host + selector
        proxy = self.proxies['https']
        urltype, proxyhost = splittype(proxy)
        proxyhost, proxyselector = splithost(proxyhost)
        i = proxyhost.find('@') + 1
        proxyhost = proxyhost[i:]
        user, passwd = self.get_user_passwd(proxyhost, realm, i)
        if not (user or passwd): return None
        proxyhost = "%s:%s@%s" % (quote(user, safe=''),
                                  quote(passwd, safe=''), proxyhost)
        self.proxies['https'] = 'https://' + proxyhost + proxyselector
        if data is None:
            return self.open(newurl)
        else:
            return self.open(newurl, data) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:19,代码来源:request.py

示例3: _parse

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def _parse(self):
        self.type, rest = splittype(self.full_url)
        if self.type is None:
            raise ValueError("unknown url type: %r" % self.full_url)
        self.host, self.selector = splithost(rest)
        if self.host:
            self.host = unquote(self.host) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:9,代码来源:request.py

示例4: set_proxy

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def set_proxy(self, host, type):
        if self.type == 'https' and not self._tunnel_host:
            self._tunnel_host = self.host
        else:
            self.type= type
            self.selector = self.full_url
        self.host = host 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:9,代码来源:request.py

示例5: has_proxy

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def has_proxy(self):
        return self.selector == self.full_url 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:4,代码来源:request.py

示例6: file_open

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def file_open(self, req):
        url = req.selector
        if url[:2] == '//' and url[2:3] != '/' and (req.host and
                req.host != 'localhost'):
            if not req.host is self.get_names():
                raise URLError("file:// scheme is supported only on localhost")
        else:
            return self.open_local_file(req)

    # names for the localhost 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:12,代码来源:request.py

示例7: open_local_file

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def open_local_file(self, req):
        import future.backports.email.utils as email_utils
        import mimetypes
        host = req.host
        filename = req.selector
        localfile = url2pathname(filename)
        try:
            stats = os.stat(localfile)
            size = stats.st_size
            modified = email_utils.formatdate(stats.st_mtime, usegmt=True)
            mtype = mimetypes.guess_type(filename)[0]
            headers = email.message_from_string(
                'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
                (mtype or 'text/plain', size, modified))
            if host:
                host, port = splitport(host)
            if not host or \
                (not port and _safe_gethostbyname(host) in self.get_names()):
                if host:
                    origurl = 'file://' + host + filename
                else:
                    origurl = 'file://' + filename
                return addinfourl(open(localfile, 'rb'), headers, origurl)
        except OSError as exp:
            # users shouldn't expect OSErrors coming from urlopen()
            raise URLError(exp)
        raise URLError('file not on local host') 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:29,代码来源:request.py

示例8: open

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def open(self, fullurl, data=None):
        """Use URLopener().open(file) instead of open(file, 'r')."""
        fullurl = unwrap(to_bytes(fullurl))
        fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|")
        if self.tempcache and fullurl in self.tempcache:
            filename, headers = self.tempcache[fullurl]
            fp = open(filename, 'rb')
            return addinfourl(fp, headers, fullurl)
        urltype, url = splittype(fullurl)
        if not urltype:
            urltype = 'file'
        if urltype in self.proxies:
            proxy = self.proxies[urltype]
            urltype, proxyhost = splittype(proxy)
            host, selector = splithost(proxyhost)
            url = (host, fullurl) # Signal special case to open_*()
        else:
            proxy = None
        name = 'open_' + urltype
        self.type = urltype
        name = name.replace('-', '_')
        if not hasattr(self, name):
            if proxy:
                return self.open_unknown_proxy(proxy, fullurl, data)
            else:
                return self.open_unknown(fullurl, data)
        try:
            if data is None:
                return getattr(self, name)(url)
            else:
                return getattr(self, name)(url, data)
        except HTTPError:
            raise
        except socket.error as msg:
            raise_with_traceback(IOError('socket error', msg)) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:37,代码来源:request.py

示例9: retry_http_basic_auth

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def retry_http_basic_auth(self, url, realm, data=None):
        host, selector = splithost(url)
        i = host.find('@') + 1
        host = host[i:]
        user, passwd = self.get_user_passwd(host, realm, i)
        if not (user or passwd): return None
        host = "%s:%s@%s" % (quote(user, safe=''),
                             quote(passwd, safe=''), host)
        newurl = 'http://' + host + selector
        if data is None:
            return self.open(newurl)
        else:
            return self.open(newurl, data) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:15,代码来源:request.py

示例10: retry_https_basic_auth

# 需要导入模块: from urllib import request [as 别名]
# 或者: from urllib.request import selector [as 别名]
def retry_https_basic_auth(self, url, realm, data=None):
        host, selector = splithost(url)
        i = host.find('@') + 1
        host = host[i:]
        user, passwd = self.get_user_passwd(host, realm, i)
        if not (user or passwd): return None
        host = "%s:%s@%s" % (quote(user, safe=''),
                             quote(passwd, safe=''), host)
        newurl = 'https://' + host + selector
        if data is None:
            return self.open(newurl)
        else:
            return self.open(newurl, data) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:15,代码来源:request.py


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