API Reference (autodoc)

This page is generated directly from the docstrings of the compiled liburlparser extension module, so it always matches the installed version. See Url Class API Reference, Host Class API Reference and PSL API Reference for narrative, example-driven documentation of the same classes.

Url

class Url(*args, **kwargs)

Bases: object

to_dict(self) → dict
to_json(self) → str
property abspath

(self) -> str

extract_dict = <nanobind.nb_func object>
extract_host = <nanobind.nb_func object>
property fragment

(self) -> str

property host

(self) -> liburlparser._urlparser_py.Host

property host_text

(self) -> str

property normalized

default port omitted, dot-segments resolved, Unicode host IDNA-normalized. See urlparser::url::normalized() for the full list.

Type:

Canonical, normalized form

property params

(self) -> list[str]

property port

(self) -> int

property protocol

(self) -> str

property query

(self) -> str

property search_params

‘+’ is a space, %XX is decoded, invalid UTF-8 becomes U+FFFD. Same shape as ada_url.parse_search_params(). params stays the raw, still-encoded ‘key=value’ string list.

Type:

Decoded query as a dict

Type:

key -> list of values (repeated keys collect every value, in order). application/x-www-form-urlencoded rules, like URLSearchParams

property userinfo

(self) -> str

Host

class Host(*args, **kwargs)

Bases: object

get_hostname(self) → liburlparser._urlparser_py.Hostname
get_ipv4(self) → liburlparser._urlparser_py.IPv4
get_ipv6(self) → liburlparser._urlparser_py.IPv6
is_hostname(self) → bool
is_ip(self) → bool
is_ipv4(self) → bool
is_ipv6(self) → bool
to_dict(self) → dict
to_json(self) → str
try_hostname(self) → object
try_ipv4(self) → object
try_ipv6(self) → object
from_url = <nanobind.nb_func object>

Psl

class Psl

Bases: object

is_loaded(self) → bool

check whether psl is loaded or not

is_suffix(self, text: str) → bool

check whether text is itself a recognized public suffix (e.g. “co.uk”), not the suffix of some hostname

load_from_path(self, filepath: str) → None

load PSL from path

load_from_string(self, string: str) → None

load PSL from string

instance = <nanobind.nb_func object>
property url

(self) -> str

psl - the global, already-loaded Psl instance

utils

flatten_dict(d)[source]
Parameters:

d (dict)

to_dict(obj, flatten=False)[source]