Skip to main content

Democritus Urls

PyPI CI Lint codecov The Democritus Project uses semver version 2.0.0 The Democritus Project uses ruff to format and lint code License: LGPL v3

Democritus functions[1] for working with URLs.

[1] Democritus functions are simple, effective, modular, well-tested, and well-documented Python functions.

We use d8s (pronounced "dee-eights") as an abbreviation for democritus (you can read more about this here).

Installation

pip install d8s-urls

Usage

You import the library like:

from d8s_urls import *

Once imported, you can use any of the functions listed below.

Functions

  • def url_scheme(url: str) -> str:
        """Return the scheme of the url."""
    
  • def url_fragment(url: str) -> str:
        """Return the fragment of the url."""
    
  • def url_examples(n: int = 10) -> List[str]:
        """Create n URLs."""
    
  • def urls_find(text: str, *, domain_name: str = '', **kwargs) -> List[str]:
        """Parse URLs from the given text. If a domain name is given, only urls with the given domain name will be returned."""
    
  • def url_canonical_form(url: str) -> str:
        """Get the canonical url."""
    
  • def url_scheme_remove(url: str):
        """Remove the scheme from the given URL."""
    
  • def url_query_strings_remove(url: str) -> str:
        """Return the URL without any query strings."""
    
  • def url_query_strings(url: str) -> Dict[str, List[str]]:
        """Return all of the query strings in the url."""
    
  • def url_query_string(url: str, query_string: str) -> List[str]:
        """Return the value of the given query string in the given url."""
    
  • def url_query_string_add(url: str, query_string_field: str, query_string_value: str) -> str:
        """."""
    
  • def url_query_string_remove(url: str, query_string_field_to_remove: str) -> str:
        """Remove the query string at the given field."""
    
  • def url_query_string_replace(url: str, query_string_field: str, query_string_value: str) -> str:
        """."""
    
  • def url_path(url: str) -> str:
        """Return the path of the url."""
    
  • def url_path_segments(url: str) -> List[str]:
        """Return all of the segments of the url path."""
    
  • def url_fragments_remove(url: str) -> str:
        """Return the URL without any fragments."""
    
  • def url_file_name(url: str) -> str:
        """Get the file name of the URL."""
    
  • def url_domain(url: str) -> str:
        """Return the domain of the given URL."""
    
  • def get_first_arg_url_domain(func):
        """If the first argument is a url, get the domain of the url and pass that into the function."""
    
  • def url_domain_second_level_name(url: str) -> str:
        """Find the second level domain name for the URL (e.g. 'http://example.com/test/bingo' => 'example') (see https://en.wikipedia.org/wiki/Domain_name#Second-level_and_lower_level_domains)."""
    
  • def url_join(url: str, path: str):
        """Join the URL to the URL path."""
    
  • def is_url(possible_url: str) -> bool:
        """Check if the given string is a URL."""
    
  • def url_screenshot(url: str, output_file_path: str = '') -> bytes:
        """."""
    
  • def url_as_punycode(url: str) -> str:
        """Convert the domain name of the URL to Punycode."""
    
  • def url_as_unicode(url: str) -> str:
        """Convert the domain name of the URL to Unicode."""
    
  • def url_simple_form(url: str) -> str:
        """Return the URL without query strings or fragments."""
    
  • def url_schemes() -> List[str]:
        """Get the url schemes from https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml."""
    
  • def url_from_google_redirect(url: str) -> Optional[str]:
        """Get the url from the google redirect."""
    
  • def url_encode(url: str) -> str:
        """Encode the URL using percent encoding (see https://en.wikipedia.org/wiki/Percent-escape)."""
    
  • def url_decode(url: str) -> str:
        """Decode a percent encoded URL (see https://en.wikipedia.org/wiki/Percent-escape)."""
    
  • def url_base_form(url: str) -> str:
        """Get the base URL without a path, query strings, or other junk."""
    
  • def url_rank(url: str) -> int:
        """."""
    

Development

👋  If you want to get involved in this project, we have some short, helpful guides below:

If you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.

Credits

This package was created with Cookiecutter and Floyd Hightower's Python project template.

Metadata

Release files for d8s-urls 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for d8s-urls 0.7.0
File Size Uploaded
d8s_urls-0.7.0.tar.gz 98.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for d8s-urls 0.7.0
File Interpreter ABI Platform
d8s_urls-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 120.0 kB

Release files / d8s_urls-0.7.0.tar.gz

Download URL d8s_urls-0.7.0.tar.gz
Size 98.2 kB
Tags Source
SHA-256 checksum
How to use checksums
109deacd5ad6a8ae5dd4a996fc086955b0c69bc2a06aa2f6018590f5b5dbaf61
BLAKE2b-256 checksum
How to use checksums
75e3d827d4f965cfb0b14e6a91c4748ce25ea909f8e2b8300e9ece298785952c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release files / d8s_urls-0.7.0-py3-none-any.whl

Download URL d8s_urls-0.7.0-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
182a745e13c2161085282b74dcb6e51694505f78b9aca35a98e109211f5ffa2d
BLAKE2b-256 checksum
How to use checksums
5e8a9b401e738d6c1aff0b44fadd65850284f2358084b731321c8f53e31abe9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page