URITools

6.0.1 · active · verified Thu Apr 09

URITools is a Python library providing comprehensive URI parsing, classification, and composition capabilities. It aims to offer a more consistent and feature-rich alternative to the standard library's `urllib.parse` for handling URIs, ensuring robust and compliant URI manipulation. The current version is 6.0.1, and it maintains a regular, though not rapid, release cadence, with major versions typically every 1-2 years.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to parse a URI string into its individual components using `urisplit` and then reconstruct it using `uricompose`. It also shows how to access specific components and parse query parameters into a dictionary.

from uritools import urisplit, uricompose

# Parse a URI into its components
uri_string = 'https://user:pass@www.example.com:8080/foo/bar?q=baz&x=y#frag'
p = urisplit(uri_string)

print(f"Scheme: {p.scheme}")
print(f"Userinfo: {p.userinfo}")
print(f"Host: {p.host}")
print(f"Port: {p.port}")
print(f"Path: {p.path}")
print(f"Query: {p.query}")
print(f"Fragment: {p.fragment}")

# Recompose the URI from its components
recomposed_uri = uricompose(p)
print(f"Recomposed URI: {recomposed_uri}")

# Example of getting query parameters
print(f"Query parameters: {p.get_query_dict()}")

view raw JSON →