Cool URLs that don’t change.
Hyperlink provides a pure-Python implementation of immutable
URLs. Based on RFC 3986 and RFC 3987, the Hyperlink URL balances
simplicity and correctness for both URIs and IRIs.
Hyperlink is tested against Python 2.7, 3.4, 3.5, 3.6, and PyPy.
For an introduction to the hyperlink library, its background, and URLs
in general, see this talk from PyConWeb 2017 (and the accompanying
Installation and Integration
Hyperlink is a pure-Python package and only depends on the standard
library. The easiest way to install is with pip:
Then, URLs are just an import away:
from hyperlink import URL
url = URL.from_text(u'http://github.com/python-hyper/hyperlink?utm_source=readthedocs')
better_url = url.replace(scheme=u'https', port=443)
org_url = better_url.click(u'.')
# prints: https://github.com/python-hyper/
# prints: readthedocs
See the API docs for more usage examples.