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


Python urllib.proxy_bypass方法代码示例

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


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

示例1: find_proxy

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import proxy_bypass [as 别名]
def find_proxy(url):
    scheme, netloc, path, pars, query, fragment = urlparse.urlparse(url)
    proxies = urllib.getproxies()
    proxyhost = None
    if scheme in proxies:
        if '@' in netloc:
            sidx = netloc.find('@') + 1
        else:
            sidx = 0
        eidx = netloc.find(':')
        if eidx == -1:
            eidx = len(netloc)
        host = netloc[sidx:eidx]
        if not (host == '127.0.0.1' or urllib.proxy_bypass(host)):
            proxyurl = proxies[scheme]
            proxyelems = urlparse.urlparse(proxyurl)
            proxyhost = proxyelems[1]
    if DEBUG:
        print >> sys.stderr, 'find_proxy: Got proxies', proxies, 'selected', proxyhost, 'URL was', url
    return proxyhost 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:22,代码来源:timeouturlopen.py

示例2: proxy_open

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import proxy_bypass [as 别名]
def proxy_open(self, req, proxy, type):
        orig_type = req.get_type()
        proxy_type, user, password, hostport = _parse_proxy(proxy)

        if proxy_type is None:
            proxy_type = orig_type

        if req.host and proxy_bypass(req.host):
            return None

        if user and password:
            user_pass = '%s:%s' % (unquote(user), unquote(password))
            creds = base64.b64encode(user_pass).strip()
            req.add_header('Proxy-authorization', 'Basic ' + creds)
        hostport = unquote(hostport)
        req.set_proxy(hostport, proxy_type)

        if orig_type == proxy_type or orig_type == 'https':
            # let other handlers take care of it
            return None
        else:
            # need to start over, because the other handlers don't
            # grok the proxy's URL type
            # e.g. if we have a constructor arg proxies like so:
            # {'http': 'ftp://proxy.example.com'}, we may end up turning
            # a request for http://acme.example.com/a into one for
            # ftp://proxy.example.com/a
            return self.parent.open(req, timeout=req.timeout) 
开发者ID:glmcdona,项目名称:meddle,代码行数:30,代码来源:urllib2.py

示例3: __init__

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import proxy_bypass [as 别名]
def __init__(self, proxies=None, proxy_bypass=None):
        if proxies is None:
            proxies = getproxies()

        assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
        self.proxies = proxies
        for type, url in proxies.items():
            setattr(self, '%s_open' % type,
                    lambda r, proxy=url, type=type, meth=self.proxy_open: \
                    meth(r, proxy, type))
        if proxy_bypass is None:
            proxy_bypass = urllib.proxy_bypass
        self._proxy_bypass = proxy_bypass 
开发者ID:rajeshmajumdar,项目名称:BruteXSS,代码行数:15,代码来源:_urllib2_fork.py

示例4: proxied

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import proxy_bypass [as 别名]
def proxied(value):
    netloc = urlparse(value).netloc
    proxied = bool(getproxies_environment()) and not proxy_bypass(netloc)
    return(proxied) 
开发者ID:oVirt,项目名称:ovirt-ansible-hosted-engine-setup,代码行数:6,代码来源:ovirt_proxied_check.py


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