• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python url.parse_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中urllib3.util.url.parse_url函数的典型用法代码示例。如果您正苦于以下问题:Python parse_url函数的具体用法?Python parse_url怎么用?Python parse_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_parse_url_unicode_python_2

    def test_parse_url_unicode_python_2(self):
        url = parse_url(u"https://www.google.com/")
        assert url == Url(u'https', host=u'www.google.com', path=u'/')

        assert isinstance(url.scheme, six.text_type)
        assert isinstance(url.host, six.text_type)
        assert isinstance(url.path, six.text_type)
开发者ID:encodeltd,项目名称:urllib3,代码行数:7,代码来源:test_util.py


示例2: __init__

    def __init__(self, proxy_url, username=None, password=None,
                 num_pools=10, headers=None, **connection_pool_kw):
        parsed = parse_url(proxy_url)

        if parsed.scheme == 'socks5':
            socks_version = socks.PROXY_TYPE_SOCKS5
        elif parsed.scheme == 'socks4':
            socks_version = socks.PROXY_TYPE_SOCKS4
        else:
            raise ValueError(
                "Unable to determine SOCKS version from %s" % proxy_url
            )

        self.proxy_url = proxy_url

        socks_options = {
            'socks_version': socks_version,
            'proxy_host': parsed.host,
            'proxy_port': parsed.port,
            'username': username,
            'password': password,
        }
        connection_pool_kw['_socks_options'] = socks_options

        super(SOCKSProxyManager, self).__init__(
            num_pools, headers, **connection_pool_kw
        )

        self.pool_classes_by_scheme = SOCKSProxyManager.pool_classes_by_scheme
开发者ID:Amber-Creative,项目名称:ambererpnext,代码行数:29,代码来源:socks.py


示例3: test_parse_url

 def test_parse_url(self):
     url_host_map = {
         "http://google.com/mail": Url("http", host="google.com", path="/mail"),
         "http://google.com/mail/": Url("http", host="google.com", path="/mail/"),
         "google.com/mail": Url(host="google.com", path="/mail"),
         "http://google.com/": Url("http", host="google.com", path="/"),
         "http://google.com": Url("http", host="google.com"),
         "http://google.com?foo": Url("http", host="google.com", path="", query="foo"),
         # Path/query/fragment
         "": Url(),
         "/": Url(path="/"),
         "?": Url(path="", query=""),
         "#": Url(path="", fragment=""),
         "#?/!google.com/?foo#bar": Url(path="", fragment="?/!google.com/?foo#bar"),
         "/foo": Url(path="/foo"),
         "/foo?bar=baz": Url(path="/foo", query="bar=baz"),
         "/foo?bar=baz#banana?apple/orange": Url(path="/foo", query="bar=baz", fragment="banana?apple/orange"),
         # Port
         "http://google.com/": Url("http", host="google.com", path="/"),
         "http://google.com:80/": Url("http", host="google.com", port=80, path="/"),
         "http://google.com:/": Url("http", host="google.com", path="/"),
         "http://google.com:80": Url("http", host="google.com", port=80),
         "http://google.com:": Url("http", host="google.com"),
         # Auth
         "http://foo:[email protected]/": Url("http", auth="foo:bar", host="localhost", path="/"),
         "http://[email protected]/": Url("http", auth="foo", host="localhost", path="/"),
         "http://foo:[email protected]@localhost/": Url("http", auth="foo:[email protected]", host="localhost", path="/"),
         "http://@": Url("http", host=None, auth=""),
     }
     for url, expected_url in url_host_map.items():
         returned_url = parse_url(url)
         self.assertEqual(returned_url, expected_url)
开发者ID:nimblemachine,项目名称:urllib3,代码行数:32,代码来源:test_util.py


示例4: test_parse_url

    def test_parse_url(self):
        url_host_map = {
            'http://google.com/mail': Url('http', host='google.com', path='/mail'),
            'http://google.com/mail/': Url('http', host='google.com', path='/mail/'),
            'google.com/mail': Url(host='google.com', path='/mail'),
            'http://google.com/': Url('http', host='google.com', path='/'),
            'http://google.com': Url('http', host='google.com'),
            'http://google.com?foo': Url('http', host='google.com', path='', query='foo'),

            # Path/query/fragment
            '': Url(),
            '/': Url(path='/'),
            '?': Url(path='', query=''),
            '#': Url(path='', fragment=''),
            '#?/!google.com/?foo#bar': Url(path='', fragment='?/!google.com/?foo#bar'),
            '/foo': Url(path='/foo'),
            '/foo?bar=baz': Url(path='/foo', query='bar=baz'),
            '/foo?bar=baz#banana?apple/orange': Url(path='/foo', query='bar=baz', fragment='banana?apple/orange'),

            # Port
            'http://google.com/': Url('http', host='google.com', path='/'),
            'http://google.com:80/': Url('http', host='google.com', port=80, path='/'),
            'http://google.com:/': Url('http', host='google.com', path='/'),
            'http://google.com:80': Url('http', host='google.com', port=80),
            'http://google.com:': Url('http', host='google.com'),

            # Auth
            'http://foo:[email protected]/': Url('http', auth='foo:bar', host='localhost', path='/'),
            'http://[email protected]/': Url('http', auth='foo', host='localhost', path='/'),
            'http://foo:[email protected]@localhost/': Url('http', auth='foo:[email protected]', host='localhost', path='/'),
            'http://@': Url('http', host=None, auth='')
        }
        for url, expected_url in url_host_map.items():
            returned_url = parse_url(url)
            self.assertEqual(returned_url, expected_url)
开发者ID:JasonRepo,项目名称:urllib3,代码行数:35,代码来源:test_util.py


示例5: test_parse_url_bytes_to_str_python_2

    def test_parse_url_bytes_to_str_python_2(self):
        url = parse_url(b"https://www.google.com/")
        assert url == Url('https', host='www.google.com', path='/')

        assert isinstance(url.scheme, str)
        assert isinstance(url.host, str)
        assert isinstance(url.path, str)
开发者ID:encodeltd,项目名称:urllib3,代码行数:7,代码来源:test_util.py


示例6: test_netloc

    def test_netloc(self):
        url_netloc_map = {
            "http://google.com/mail": "google.com",
            "http://google.com:80/mail": "google.com:80",
            "google.com/foobar": "google.com",
            "google.com:12345": "google.com:12345",
        }

        for url, expected_netloc in url_netloc_map.items():
            self.assertEqual(parse_url(url).netloc, expected_netloc)
开发者ID:by46,项目名称:urllib3,代码行数:10,代码来源:test_util.py


示例7: test_parse_url_normalization

 def test_parse_url_normalization(self):
     """Assert parse_url normalizes the scheme/host, and only the scheme/host"""
     test_urls = [
         ('HTTP://GOOGLE.COM/MAIL/', 'http://google.com/MAIL/'),
         ('HTTP://JeremyCline:[email protected]:8080/', 'http://JeremyCline:[email protected]:8080/'),
         ('HTTPS://Example.Com/?Key=Value', 'https://example.com/?Key=Value'),
         ('Https://Example.Com/#Fragment', 'https://example.com/#Fragment'),
     ]
     for url, expected_normalized_url in test_urls:
         actual_normalized_url = parse_url(url).url
         self.assertEqual(actual_normalized_url, expected_normalized_url)
开发者ID:Disassem,项目名称:urllib3,代码行数:11,代码来源:test_util.py


示例8: test_request_uri

 def test_request_uri(self):
     url_host_map = {
         "http://google.com/mail": "/mail",
         "http://google.com/mail/": "/mail/",
         "http://google.com/": "/",
         "http://google.com": "/",
         "": "/",
         "/": "/",
         "?": "/?",
         "#": "/",
         "/foo?bar=baz": "/foo?bar=baz",
     }
     for url, expected_request_uri in url_host_map.items():
         returned_url = parse_url(url)
         self.assertEqual(returned_url.request_uri, expected_request_uri)
开发者ID:by46,项目名称:urllib3,代码行数:15,代码来源:test_util.py


示例9: test_request_uri

 def test_request_uri(self):
     url_host_map = {
         'http://google.com/mail': '/mail',
         'http://google.com/mail/': '/mail/',
         'http://google.com/': '/',
         'http://google.com': '/',
         '': '/',
         '/': '/',
         '?': '/?',
         '#': '/',
         '/foo?bar=baz': '/foo?bar=baz',
     }
     for url, expected_request_uri in url_host_map.items():
         returned_url = parse_url(url)
         self.assertEqual(returned_url.request_uri, expected_request_uri)
开发者ID:Lukasa,项目名称:urllib3,代码行数:15,代码来源:test_util.py


示例10: validate_run_info

def validate_run_info(info: dict) -> bool:
	passed = False
	# ## Validate Binary Executable ## #
	binary = Path(shutil.which(info["binary"]))
	if binary.exists():
		passed = True
	else:
		logger.error("binary", binary, "is not accessible from this process")
	# ## Check the URL For Validity ## #
	# ##   By Checking It's Parts   ## #
	link = url.parse_url(runInfo["target"])
	for x in [link.hostname, link.path, link.url]:
		if x is not None:
			passed = True
		else:
			passed = False
			break  # don't let other "True" values corrupt the state
	return passed
开发者ID:osirisgothra,项目名称:autox,代码行数:18,代码来源:sw.py


示例11: test_parse_url

 def test_parse_url(self):
     for url, expected_Url in chain(self.parse_url_host_map,
                                    self.non_round_tripping_parse_url_host_map.items()):
         returned_Url = parse_url(url)
         self.assertEqual(returned_Url, expected_Url)
开发者ID:Lukasa,项目名称:urllib3,代码行数:5,代码来源:test_util.py


示例12: test_url_vulnerabilities

 def test_url_vulnerabilities(self, url, expected_url):
     if expected_url is False:
         with pytest.raises(LocationParseError):
             parse_url(url)
     else:
         assert parse_url(url) == expected_url
开发者ID:encodeltd,项目名称:urllib3,代码行数:6,代码来源:test_util.py


示例13: test_netloc

 def test_netloc(self, url, expected_netloc):
     assert parse_url(url).netloc == expected_netloc
开发者ID:encodeltd,项目名称:urllib3,代码行数:2,代码来源:test_util.py


示例14: test_request_uri

 def test_request_uri(self, url, expected_request_uri):
     returned_url = parse_url(url)
     assert returned_url.request_uri == expected_request_uri
开发者ID:encodeltd,项目名称:urllib3,代码行数:3,代码来源:test_util.py


示例15: test_parse_url_negative_port

 def test_parse_url_negative_port(self):
     with pytest.raises(LocationParseError):
         parse_url("https://www.google.com:-80/")
开发者ID:encodeltd,项目名称:urllib3,代码行数:3,代码来源:test_util.py


示例16: test_parse_url_invalid_IPv6

 def test_parse_url_invalid_IPv6(self):
     with pytest.raises(LocationParseError):
         parse_url('[::1')
开发者ID:encodeltd,项目名称:urllib3,代码行数:3,代码来源:test_util.py


示例17: test_parse_url

 def test_parse_url(self, url, expected_url):
     returned_url = parse_url(url)
     assert returned_url == expected_url
开发者ID:encodeltd,项目名称:urllib3,代码行数:3,代码来源:test_util.py


示例18: test_parse_url_normalization

 def test_parse_url_normalization(self, url, expected_normalized_url):
     """Assert parse_url normalizes the scheme/host, and only the scheme/host"""
     actual_normalized_url = parse_url(url).url
     assert actual_normalized_url == expected_normalized_url
开发者ID:encodeltd,项目名称:urllib3,代码行数:4,代码来源:test_util.py


示例19: test_parse_url_invalid_IPv6

 def test_parse_url_invalid_IPv6(self):
     with pytest.raises(ValueError):
         parse_url('[::1')
开发者ID:cloudera,项目名称:hue,代码行数:3,代码来源:test_util.py


示例20: get_client

 def get_client(self, device_id, secret):
     client = LocalClient(device_id, secret)
     parsed_url = parse_url(self.liveserver.url)
     client.host = parsed_url.host
     client.port = parsed_url.port
     return client
开发者ID:keybar,项目名称:keybar,代码行数:6,代码来源:helpers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python urlnorm.norm函数代码示例发布时间:2022-05-27
下一篇:
Python ssl_.ssl_wrap_socket函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap