Python parse.urlparse方法代码示例

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

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

示例1: get_plugin_config

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def get_plugin_config(config_uri):
    """
    Downloads/opens configuration yaml file, returns
    dict of Galaxy plugins
    """
    # Try to open the URI as a URL or fall back to opening local file
    try:
        config_uri_parsed = urlparse(config_uri)
        if config_uri_parsed.scheme in ['https', 'http']:
            url = urlopen(config_uri)
            yaml_data = url.read()
        else:
            with open(config_uri, 'r') as file_data:
                yaml_data = file_data.read()
    except URLError as e:
        print(e)
    # Parse the YAML configuration
    try:
        plugin_data = yaml.safe_load(yaml_data)
        return plugin_data['plugins']
    except yaml.YAMLError as e:
        print(e) 
开发者ID:Slashbunny,项目名称:gog-galaxy-plugin-downloader,代码行数:26,代码来源:download.py


示例2: urlParser

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def urlParser(target):
    log = logging.getLogger('urlparser')
    ssl = False
    o = urlparse(target)
    if o[0] not in ['http', 'https', '']:
        log.error('scheme %s not supported' % o[0])
        return
    if o[0] == 'https':
        ssl = True
    if len(o[2]) > 0:
        path = o[2]
    else:
        path = '/'
    tmp = o[1].split(':')
    if len(tmp) > 1:
        port = tmp[1]
    else:
        port = None
    hostname = tmp[0]
    query = o[4]
    return (hostname, port, path, query, ssl) 
开发者ID:EnableSecurity,项目名称:wafw00f,代码行数:24,代码来源:evillib.py


示例3: _get_prom_url

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def _get_prom_url(self):
        # Get promenade url from Keystone session object
        ks_session = self._get_ks_session()
        try:
            prom_endpoint = ks_session.get_endpoint(
                interface='internal', service_type='kubernetesprovisioner')
        except exc.EndpointNotFound:
            self.logger.error("Could not find an internal interface"
                              " defined in Keystone for Promenade")
            raise errors.DriverError("Could not find an internal interface"
                                     " defined in Keystone for Promenade")
        prom_url = urlparse(prom_endpoint)
        return prom_url 
开发者ID:airshipit,项目名称:drydock,代码行数:20,代码来源:promenade_client.py


示例4: test_connection

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def test_connection(name, url, timeout=10):
    """Simple connection test"""
    urlinfo = urlparse(url)
    start = time.time()
    try:
        ip = socket.gethostbyname(urlinfo.netloc)
    except Exception as e:
        print('Error resolving DNS for {}: {}, {}'.format(name, url, e))
        return
    dns_elapsed = time.time() - start
    start = time.time()
    try:
        _ = urlopen(url, timeout=timeout)
    except Exception as e:
        print("Error open {}: {}, {}, DNS finished in {} sec.".format(name, url, e, dns_elapsed))
        return
    load_elapsed = time.time() - start
    print("Timing for {}: {}, DNS: {:.4f} sec, LOAD: {:.4f} sec.".format(name, url, dns_elapsed, load_elapsed)) 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:20,代码来源:diagnose.py


示例5: get_connection

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def get_connection(self, url, proxies=None):
        proxies = proxies or {}
        proxy = proxies.get(urlparse(url.lower()).scheme)
        if proxy:
            raise ValueError('%s does not support specifying proxies' %
                             self.__class__.__name__)
        with self.pools.lock:
            pool = self.pools.get(url)
            if pool:
                return pool
            pool = UsbmuxHTTPConnectionPool(url, self.timeout)
            self.pools[url] = pool
        return pool 
开发者ID:openatx,项目名称:facebook-wda,代码行数:19,代码来源:requests_usbmux.py


示例6: extract_domains

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def extract_domains(self, resp):
        link_regx = re.compile('<cite.*?>(.*?)<\/cite>')
        try:
            links_list = link_regx.findall(resp)
            for link in links_list:
                link = re.sub('<span.*>', '', link)
                if not link.startswith('http'):
                    link = "http://" + link
                subdomain = urlparse.urlparse(link).netloc
                if subdomain and subdomain not in self.subdomains and subdomain != self.domain:
                    if self.verbose:
                        self.print_("%s%s: %s%s" % (R, self.engine_name, W, subdomain))
                    self.subdomains.append(subdomain.strip())
        except Exception:
            pass
        return links_list 
开发者ID:kp625544,项目名称:subtake,代码行数:18,代码来源:sublist3r.py


示例7: _create_request_from_scope

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def _create_request_from_scope(self, send: Callable) -> Request:
        headers = Headers()
        headers["Remote-Addr"] = (self.scope.get("client") or ["<local>"])[0]
        for name, value in self.scope["headers"]:
            headers.add(name.decode("latin1").title(), value.decode("latin1"))
        if self.scope["http_version"] < "1.1":
            headers.setdefault("Host", self.app.config["SERVER_NAME"] or "")
        path = self.scope["path"]
        path = path if path[0] == "/" else urlparse(path).path
        return self.app.request_class(
            self.scope["method"],
            self.scope["scheme"],
            path,
            self.scope["query_string"],
            headers,
            self.scope.get("root_path", ""),
            self.scope["http_version"],
            max_content_length=self.app.config["MAX_CONTENT_LENGTH"],
            body_timeout=self.app.config["BODY_TIMEOUT"],
            send_push_promise=partial(self._send_push_promise, send),
            scope=self.scope,
        ) 
开发者ID:pgjones,项目名称:quart,代码行数:26,代码来源:asgi.py


示例8: _create_websocket_from_scope

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def _create_websocket_from_scope(self, send: Callable) -> Websocket:
        headers = Headers()
        headers["Remote-Addr"] = (self.scope.get("client") or ["<local>"])[0]
        for name, value in self.scope["headers"]:
            headers.add(name.decode("latin1").title(), value.decode("latin1"))
        path = self.scope["path"]
        path = path if path[0] == "/" else urlparse(path).path
        return self.app.websocket_class(
            path,
            self.scope["query_string"],
            self.scope["scheme"],
            headers,
            self.scope.get("root_path", ""),
            self.scope.get("http_version", "1.1"),
            self.scope.get("subprotocols", []),
            self.queue.get,
            partial(self.send_data, send),
            partial(self.accept_connection, send),
        ) 
开发者ID:pgjones,项目名称:quart,代码行数:23,代码来源:asgi.py


示例9: test_url_attributes_with_ssl_dict

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def test_url_attributes_with_ssl_dict(app, path, query, expected_url):
    current_dir = os.path.dirname(os.path.realpath(__file__))
    ssl_cert = os.path.join(current_dir, "certs/selfsigned.cert")
    ssl_key = os.path.join(current_dir, "certs/selfsigned.key")
    ssl_dict = {"cert": ssl_cert, "key": ssl_key}
    async def handler(request):
        return text("OK")
    app.add_route(handler, path)
    request, response = app.test_client.get(
        f"https://{HOST}:{PORT}" + path + f"?{query}",
        server_kwargs={"ssl": ssl_dict},
    )
    assert request.url == expected_url.format(HOST, request.server_port)
    parsed = urlparse(request.url)
    assert parsed.scheme == request.scheme
    assert parsed.path == request.path
    assert parsed.query == request.query_string
    assert parsed.netloc == request.host 
开发者ID:huge-success,项目名称:sanic,代码行数:27,代码来源:test_requests.py


示例10: read

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def read(self):
        try:
            from PIL import Image
            from pyzbar.pyzbar import decode
            decoded_data = decode(Image.open(self.filename))
            if path.isfile(self.filename):
                remove(self.filename)
            try:
                url = urlparse(decoded_data[0].data.decode())
                query_params = parse_qsl(url.query)
                self._codes = dict(query_params)
                return self._codes.get("secret")
            except (KeyError, IndexError):
                Logger.error("Invalid QR image")
                return None
        except ImportError:
            from ..application import Application
            Application.USE_QRSCANNER = False
            QRReader.ZBAR_FOUND = False 
开发者ID:bilelmoussaoui,项目名称:Authenticator,代码行数:21,代码来源:qr_reader.py


示例11: dedup_link

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def dedup_link(urls):
    host = []
    _ = []
    furls = []
    for i in set(urls):
        # 只保留有参数的url其余的略过
        if '=' in i and not re.search(r"'|@|\+", i):
            #  判断url是不是伪静态,伪静态与普通的去重方法不一样
            if re.search(r'/\?\d+=', i):
                furls.append(i)
            else:
                # 通过urlparse 对url进行去参去重,相同的丢弃
                url = parse.urlparse(i)
                if url.netloc + url.path not in host:
                    host.append(url.netloc + url.path)
                    _.append(i)
    _.extend(diff(furls))
    return _ 
开发者ID:al0ne,项目名称:Vxscan,代码行数:20,代码来源:url.py


示例12: __init__

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def __init__(self,session,**kwargs):
        tools.Options.__init__(self,**kwargs)
        self._session = session
        url = urlparse(self._session.conn_url)
        self._secure = False
        if url[0] == "https":
            self._secure = True
        s = url[1].split(":")
        self._host = s[0]
        self._port = s[1]
        self._websocket = None
        self._handshakeComplete = False
        self._headers = None
        self._authorization = None 
开发者ID:sassoftware,项目名称:python-esppy,代码行数:23,代码来源:connections.py


示例13: validate_link

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def validate_link(self, link, bookmark=False):
        """Checks if the given link can get correct data."""
        # removes the scheme and net location parts of the link
        url_parts = list(urlparse.urlparse(link))
        url_parts[0] = url_parts[1] = ''
        # bookmark link should not have the version in the URL
        if bookmark and url_parts[2].startswith(PATH_PREFIX):
            return False
        full_path = urlparse.urlunparse(url_parts)
        try:
            self.get_json(full_path, path_prefix='')
            return True
        except Exception:
            return False 
开发者ID:openstack,项目名称:zun,代码行数:18,代码来源:base.py


示例14: do_GET

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def do_GET(self):
        (scm, netloc, path, params, query, fragment) = urlparse(self.path, "http")
        if scm != "http" or fragment or not netloc:
            self.send_error(400, "bad url %s" % self.path)
            return
        soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            if self._connect_to(netloc, soc):
                self.log_request()
                soc.send(
                    "%s %s %s\r\n" % (self.command, urlunparse(("", "", path, params, query, "")), self.request_version)
                )
                self.headers["Connection"] = "close"
                del self.headers["Proxy-Connection"]
                for key_val in self.headers.items():
                    soc.send("%s: %s\r\n" % key_val)
                soc.send("\r\n")
                self._read_write(soc)
        finally:
            logging.warning("Finished do_GET()")
            soc.close()
            self.connection.close() 
开发者ID:nabla-c0d3,项目名称:sslyze,代码行数:24,代码来源:tiny_proxy.py


示例15: extract_http_scheme_host_port

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def extract_http_scheme_host_port(http_url):
    '''Extract scheme, host and port from a HTTP URL.
    :param http_url: HTTP URL to extract.
    :type http_url: ``string``
    :returns: A tuple of scheme, host and port
    :rtype: ``tuple``
    :raises ValueError: If `http_url` is not in http(s)://hostname:port format.
    '''
    try:
        http_info = urlparse.urlparse(http_url)
    except Exception:
        raise ValueError(
            str(http_url) + " is not in http(s)://hostname:port format")
    if not http_info.scheme or not http_info.hostname or not http_info.port:
        raise ValueError(
            http_url + " is not in http(s)://hostname:port format")
    return (http_info.scheme, http_info.hostname, http_info.port) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:24,代码来源:utils.py


示例16: __init__

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def __init__(self, splunkd_uri, session_key, schema):
        """
        Global Config.
        :param splunkd_uri:
        :param session_key:
        :param schema:
        :type schema: GlobalConfigSchema
        """
        self._splunkd_uri = splunkd_uri
        self._session_key = session_key
        self._schema = schema
        splunkd_info = urlparse(self._splunkd_uri)
        self._client = SplunkRestClient(
            self._session_key,
            self._schema.product,
            scheme=splunkd_info.scheme,
            host=splunkd_info.hostname,
            port=splunkd_info.port,
        )
        self._configuration = Configuration(self._client, self._schema)
        self._inputs = Inputs(self._client, self._schema)
        self._configs = Configs(self._client, self._schema)
        self._settings = Settings(self._client, self._schema) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:27,代码来源:__init__.py


示例17: init_session

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def init_session(self, node):
        """Initialize a Libvirt session to the node hypervisor.
        :param node: instance of objects.BaremetalNode
        """
        if node.oob_type != 'libvirt':
            raise errors.DriverError(
                "Node OOB type %s is not 'libvirt'" % node.oob_type)
        virsh_url = node.oob_parameters.get('libvirt_uri', None)
        if not virsh_url:
            raise errors.DriverError(
                "Node %s has no 'libvirt_url' defined" % (node.name))
        url_parts = urlparse(virsh_url)
        if url_parts.scheme != "qemu+ssh":
            raise errors.DriverError(
                "Node %s has invalid libvirt URL scheme %s. "
                "Only 'qemu+ssh' supported." % (node.name, url_parts.scheme))
        self.logger.debug(
            "Starting libvirt session to hypervisor %s " % (virsh_url))
        virsh_ses = libvirt.open(virsh_url)
        if not virsh_ses:
            raise errors.DriverError(
                "Unable to establish libvirt session to %s." % virsh_url)
        return virsh_ses 
开发者ID:airshipit,项目名称:drydock,代码行数:33,代码来源:oob.py


示例18: cached_path

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def cached_path(url_or_filename: Union[str, Path], cache_dir: Union[str, Path] = None) -> str:
    """
    Given something that might be a URL (or might be a local path),
    determine which. If it's a URL, download the file and cache it, and
    return the path to the cached file. If it's already a local path,
    make sure the file exists and then return the path.
    """
    if cache_dir is None:
        cache_dir = PYTORCH_PRETRAINED_BERT_CACHE
    if isinstance(url_or_filename, Path):
        url_or_filename = str(url_or_filename)
    if isinstance(cache_dir, Path):
        cache_dir = str(cache_dir)
    parsed = urlparse(url_or_filename)
    if parsed.scheme in ('http', 'https', 's3'):
        # URL, so get it from the cache (downloading if necessary)
        return get_from_cache(url_or_filename, cache_dir)
    elif os.path.exists(url_or_filename):
        # File, and it exists.
        return url_or_filename
    elif parsed.scheme == '':
        # File, but it doesn't exist.
        raise FileNotFoundError("file {} not found".format(url_or_filename))
    else:
        # Something unknown
        raise ValueError("unable to parse {} as a URL or as a local path".format(url_or_filename)) 
开发者ID:ymcui,项目名称:cmrc2019,代码行数:30,代码来源:file_utils.py


示例19: split_s3_path

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def split_s3_path(url: str) -> Tuple[str, str]:
    """Split a full s3 path into the bucket name and path."""
    parsed = urlparse(url)
    if not parsed.netloc or not parsed.path:
        raise ValueError("bad s3 path {}".format(url))
    bucket_name = parsed.netloc
    s3_path = parsed.path
    # Remove '/' at beginning of path.
    if s3_path.startswith("/"):
        s3_path = s3_path[1:]
    return bucket_name, s3_path 
开发者ID:ymcui,项目名称:cmrc2019,代码行数:13,代码来源:file_utils.py


示例20: _parse_redirect_uri

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def _parse_redirect_uri(self, redirect_uri):
        parsed = urlparse(redirect_uri)
        self.full_uri = redirect_uri
        self.endpoint = parsed.path.lstrip('/') 
开发者ID:zamzterz,项目名称:Flask-pyoidc,代码行数:6,代码来源:redirect_uri_config.py


示例21: test_authentication_request

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def test_authentication_request(self):
        extra_user_auth_params = {'foo': 'bar', 'abc': 'xyz'}
        config = ProviderConfiguration(provider_metadata=self.PROVIDER_METADATA,
                                       client_metadata=self.CLIENT_METADATA,
                                       auth_request_params=extra_user_auth_params)
        state = 'test_state'
        nonce = 'test_nonce'
        facade = PyoidcFacade(config, self.REDIRECT_URI)
        extra_lib_auth_params = {'foo': 'baz', 'qwe': 'rty'}
        auth_request = facade.authentication_request(state, nonce, extra_lib_auth_params)
        assert auth_request.startswith(self.PROVIDER_METADATA['authorization_endpoint'])
        auth_request_params = dict(parse_qsl(urlparse(auth_request).query))
        expected_auth_params = {
            'scope': 'openid',
            'response_type': 'code',
            'client_id': self.CLIENT_METADATA['client_id'],
            'redirect_uri': self.REDIRECT_URI,
            'state': state,
            'nonce': nonce
        }
        expected_auth_params.update(extra_user_auth_params)
        expected_auth_params.update(extra_lib_auth_params)
        assert auth_request_params == expected_auth_params 
开发者ID:zamzterz,项目名称:Flask-pyoidc,代码行数:28,代码来源:test_pyoidc_facade.py


示例22: test_logout_redirects_to_provider_if_end_session_endpoint_is_configured

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def test_logout_redirects_to_provider_if_end_session_endpoint_is_configured(self, post_logout_redirect_uri):
        end_session_endpoint = 'https://provider.example.com/end_session'
        client_metadata = {}
        if post_logout_redirect_uri:
            client_metadata['post_logout_redirect_uris'] = [post_logout_redirect_uri]
        authn = self.init_app(provider_metadata_extras={'end_session_endpoint': end_session_endpoint},
                              client_metadata_extras=client_metadata)
        logout_view_mock = self.get_view_mock()
        id_token = IdToken(**{'sub': 'sub1', 'nonce': 'nonce'})
        # register logout view
        view_func = authn.oidc_logout(logout_view_mock)
        self.app.add_url_rule('/logout', view_func=view_func)
        with self.app.test_request_context('/logout'):
            UserSession(flask.session, self.PROVIDER_NAME).update(access_token='test_access_token',
                                                                  id_token=id_token.to_dict(),
                                                                  id_token_jwt=id_token.to_jwt(),
                                                                  userinfo={'sub': 'user1'})
            end_session_redirect = view_func()
            # ensure user session has been cleared
            assert all(k not in flask.session for k in UserSession.KEYS)
            parsed_request = dict(parse_qsl(urlparse(end_session_redirect.headers['Location']).query))
            assert parsed_request['state'] == flask.session['end_session_state']
        assert end_session_redirect.status_code == 303
        assert end_session_redirect.location.startswith(end_session_endpoint)
        assert IdToken().from_jwt(parsed_request['id_token_hint']) == id_token
        expected_post_logout_redirect_uri = post_logout_redirect_uri if post_logout_redirect_uri else 'http://{}/logout'.format(self.CLIENT_DOMAIN)
        assert parsed_request['post_logout_redirect_uri'] == expected_post_logout_redirect_uri
        assert not logout_view_mock.called 
开发者ID:zamzterz,项目名称:Flask-pyoidc,代码行数:35,代码来源:test_flask_pyoidc.py


示例23: get_file_name

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def get_file_name(self, url):
        parsed = urlparse(url)
        name, ext = os.path.splitext(os.path.basename(parsed.path))
        if not ext:
            name, ext = os.path.splitext(os.path.basename(parsed.query.replace("=", "/")))
        ext = ext.lower()
        fname = name + ext
        return fname 
开发者ID:icoxfog417,项目名称:mlimages,代码行数:10,代码来源:file_api.py


示例24: get_domain

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def get_domain(url):
    url_parsed = urlparse(url)
    return url_parsed.netloc
    # if "://" in url:
    #     url = url.split("://")[1]
    # if "/" in url:
    #     url = url.split("/")[0]
    # return url.strip() 
开发者ID:invanalabs,项目名称:invana-bot,代码行数:11,代码来源:url.py


示例25: get_absolute_url

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def get_absolute_url(url=None, origin_url=None):
    url = url.lstrip("/")
    url_parsed = urlparse(origin_url)
    scheme = url_parsed.scheme
    host = url_parsed.netloc
    if "://" in url:
        return url
    else:
        url = "{}://{}/{}".format(scheme, host, url)
        return url 
开发者ID:invanalabs,项目名称:invana-bot,代码行数:13,代码来源:url.py


示例26: test_submitting_schema_edit_form_redirects_to_preview

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def test_submitting_schema_edit_form_redirects_to_preview(self, testapp):
        ''' Submitting the form to edit a schema field changes the correct value in the database
        '''
        department = Department.create(name="B Police Department", short_name="BPD", load_defaults=True)
        # set up a user
        create_and_log_in_user(testapp, department)
        # make a request to specific front page
        response = testapp.get("/department/{}/edit/schema/complaints".format(department.id))
        assert response.status_code == 200
        # submit new title & content
        assert 'editShiftTitleContentAndOrder' in response.forms
        form = response.forms['editShiftTitleContentAndOrder']
        new_title = "A New Data Field Title"
        new_content = "A Short Definition of this Data Field"
        new_order = 99
        form['chart_title'] = new_title
        form['chart_content'] = new_content
        form['chart_order'] = new_order
        response = form.submit()
        # the response should be a redirect
        assert response.status_code == 302
        # the location of the redirect should be the preview page
        parsed = urlparse(response.location)
        assert parsed.path == "/department/{}/preview/schema/complaints".format(department.id) 
开发者ID:codeforamerica,项目名称:comport,代码行数:30,代码来源:test_admin_forms.py


示例27: filter_result

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlparse [as 别名]
def filter_result(link):
    try:
        # Valid results are absolute URLs not pointing to a Google domain
        # like images.google.com or googleusercontent.com
        o = urlparse(link, 'http')
        if o.netloc and 'google' not in o.netloc:
            return link
        # Decode hidden URLs.
        if link.startswith('/url?'):
            link = parse_qs(o.query)['q'][0]
            # Valid results are absolute URLs not pointing to a Google domain
            # like images.google.com or googleusercontent.com
            o = urlparse(link, 'http')
            if o.netloc and 'google' not in o.netloc:
                return link
    # Otherwise, or on error, return None.
    except Exception:
        pass
    return None
# Shortcut to search images
# Beware, this does not return the image link. 
开发者ID:the-robot,项目名称:sqliv,代码行数:29,代码来源:google.py



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