hyperlink

Featureful, immutable, and correct URL handling library for Python.

pipmacoslinuxwindows
Try with needOr install directly
Source

About

A featureful, immutable, and correct URL for Python.

Examples

parse and validate URL strings in Python$ python -c "from hyperlink import URL; u = URL.from_text('https://example.com/path'); print(u)"
extract hostname and port from URL$ python -c "from hyperlink import URL; u = URL.from_text('https://example.com:8080/path'); print(u.host, u.port)"
modify URL query parameters safely$ python -c "from hyperlink import URL; u = URL.from_text('https://example.com?foo=bar'); u2 = u.add('baz', 'qux'); print(u2.to_text())"
build URLs programmatically from components$ python -c "from hyperlink import URL; u = URL(scheme='https', host='example.com', path=['api', 'v1']); print(u.to_text())"
normalize and compare URLs for equality$ python -c "from hyperlink import URL; u1 = URL.from_text('https://example.com'); u2 = URL.from_text('https://example.com/'); print(u1 == u2)"