Url
- class Url
Description
URLas described using the Uniform Resource Identifier (URI) specification (RFC3986).Raises
RuntimeErroron invalid URLs, including those with unicode characters. Unicode characters must be percent escaped by encoding them as hex with%escape. Url components are accessible both as encoded and decoded strings.Encoded strings use
.encodedproperties and returns strings exactly as they appear in the URL.Otherwise properties and methods operate on decoded strings. Retrieving a decoded string unescapes percent-encoded octets with the corresponding characters.
Note that an empty component is distinct from no component, however getters will return empty strings for missing components.
Documentation is based on Boost.URL.
Inheritance:
Members defined in
Url(52 members)RReturn the authority
RReturn the authority.
RReturn the fragment
RReturn the host
RReturn the host
RReturn the host and port
RReturn the host name
RReturn the origin
RReturn the query as a sequence of parameters
RReturn the password
RReturn the path
RReturn the query
RReturn the resource
RReturn the target
RReturn the user
RReturn the userinfo
RReturn the IPv6 Zone ID
RReturn the fragment
RReturn true if an authority is present
RReturn true if a fragment is present
RReturn true if a password is present
RReturn true if a port is present
RReturn true if a query is present
RReturns true if a scheme is present
RReturn true if a userinfo is present
RReturn the host
RReturn the host
RReturn the host IPv4 address
RReturn the host IPv6 address
RReturn the host IPvFuture address
RReturn the host name
RReturn the host type
RReturn true if the path is absolute
RReturn the password
RReturn the path
RReturn the port
RReturn the port
RReturn the query
RReturns the scheme
RReturn the scheme
RReturn the user
RReturn the userinfo
RReturn the IPv6 Zone ID
Returns true if the url is not empty
Returns the number of characters in the url
Return the query as a sequence of parameters
Attributes
- property encoded_host_and_port: str
Return the host and port
If an authority is present, this returns the host and optional port as a string, which may be empty. Otherwise it returns an empty string.
- property encoded_host_name: str
Return the host name
If the host type is
Name, this returns the name as a string. Otherwise, returns an empty string.
- property encoded_origin: str
Return the origin
If an authority is present, this returns the scheme and authority portion of the url. Otherwise, an empty string is returned.
- property encoded_params: list[tuple[str, str | None]]
Return the query as a sequence of parameters
This returns a bidirectional sequence of key/value pairs over the query. Strings returned when iterating the range may contain percent escapes. Changes to the container are not reflected in the underlying URL.
- property encoded_password: str
Return the password
This returns the password portion of the userinfo as a percent-encoded string.
- property encoded_resource: str
Return the resource
This returns the resource, which is the portion of the url that includes only the path, query, and fragment.
- property encoded_target: str
Return the target
This returns the target, which is the portion of the url that includes only the path and query.
- property encoded_zone_id: str
Return the IPv6 Zone ID
If the host type is
IPv6, this returns the Zone ID as a string. Otherwise an empty string is returned.
- property fragment: str
Return the fragment
This calculates the fragment of the url, with percent escapes decoded and without the leading pound sign (‘#’) whose presence indicates that the url contains a fragment.
- property has_authority: bool
Return true if an authority is present
This returns true if the url contains an authority. The presence of an authority is denoted by a double slash (“//”) at the beginning or after the scheme.
- property has_password: bool
Return true if a password is present
This returns true if the userinfo is present and contains a password.
- property has_port: bool
Return true if a port is present
This returns true if an authority is present and contains a port.
- property has_query: bool
Return true if a query is present
This returns true if this contains a query.
- property host_ipv4_address: syside.IPv4Address
Return the host IPv4 address
If the host type is
IPv4, this returns the address. Otherwise, returns a default-constructed value which is equal to the unspecified address “0.0.0.0”.
- property host_ipv6_address: syside.IPv6Address
Return the host IPv6 address
If the host type is
IPv6, this returns the address. Otherwise, returns a default-constructed value which is equal to the unspecified address “0:0:0:0:0:0:0:0”.
- property host_ipvfuture: str
Return the host IPvFuture address
If the host type is
IPvFuture, this returns the address as a string. Otherwise, returns an empty string.
- property host_name: str
Return the host name
If the host type is
Name, this returns the name as a string. Otherwise, returns an empty string.
- property host_type: syside.HostType
Return the host type
This returns one of the following constants representing the type of host present.
HostType.IPv4HostType.IPv6HostType.IPvFutureHostType.NameHostType.none
When
has_authorityis false, the host type isHostType.none.
- property is_path_absolute: bool
Return true if the path is absolute
This returns true if the path begins with a forward slash (‘/’)
- property port_number: int
Return the port
If a port is present and the numerical value is representable, it is returned as an unsigned integer. Otherwise, the number zero is returned.
- property query: str
Return the query
When plus signs appear in the query portion of the url, they are converted to spaces automatically upon decoding.
- property scheme_id: syside.Scheme
Return the scheme
This returns a value which depends on the scheme in the url:
If the scheme is a well-known scheme, corresponding value from the enumeration
Schemeis returned.If a scheme is present but is not a well-known scheme, the value returned is
Scheme.Unknown.Otherwise, the value returned is
Scheme.none.
- property zone_id: str
Return the IPv6 Zone ID
If the host type is
IPv6, this returns the Zone ID as a string. Otherwise an empty string is returned.
Methods
- __copy__() syside.Url
- __deepcopy__() syside.Url
- __init__(arg: str, /) None
- params(options: syside.EncodingOpts = ...) list[tuple[str, str | None]]
Return the query as a sequence of parameters
This function returns a bidirectional sequence of key/value pairs over the query. Any percent-escapes in strings returned when iterating the view are decoded first. Changes to the container are not reflected in the underlying URL.
Used by