Skip to main content

Democritus functions for working with URLs.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

d8s_urls-0.7.0.tar.gz (98.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

d8s_urls-0.7.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file d8s_urls-0.7.0.tar.gz.

File metadata

  • Download URL: d8s_urls-0.7.0.tar.gz
  • Upload date:
  • Size: 98.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for d8s_urls-0.7.0.tar.gz
Algorithm Hash digest
SHA256 109deacd5ad6a8ae5dd4a996fc086955b0c69bc2a06aa2f6018590f5b5dbaf61
MD5 1e65521f42d9ceac75dbb17d1856470c
BLAKE2b-256 75e3d827d4f965cfb0b14e6a91c4748ce25ea909f8e2b8300e9ece298785952c

See more details on using hashes here.

Provenance

The following attestation bundles were made for d8s_urls-0.7.0.tar.gz:

Publisher: release-please.yml on democritus-project/d8s-urls

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file d8s_urls-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: d8s_urls-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for d8s_urls-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 182a745e13c2161085282b74dcb6e51694505f78b9aca35a98e109211f5ffa2d
MD5 dced7aa71c6d684935858aac0c7edd26
BLAKE2b-256 5e8a9b401e738d6c1aff0b44fadd65850284f2358084b731321c8f53e31abe9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for d8s_urls-0.7.0-py3-none-any.whl:

Publisher: release-please.yml on democritus-project/d8s-urls

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page