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 black to format 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.6.0.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

d8s_urls-0.6.0-py2.py3-none-any.whl (24.6 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: d8s_urls-0.6.0.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for d8s_urls-0.6.0.tar.gz
Algorithm Hash digest
SHA256 391064b5443bd0034055e5535e89a63974e50c3141dfd4a8c19c04d4995bbe1c
MD5 89771d6937f84c75ddc374ec4f34030f
BLAKE2b-256 5289e8addeb075ba5e6b299998c8572fb0e5b8bd43b372a0dd9516cc5bf4b393

See more details on using hashes here.

File details

Details for the file d8s_urls-0.6.0-py2.py3-none-any.whl.

File metadata

  • Download URL: d8s_urls-0.6.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for d8s_urls-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9416567d3e7c1b69e274a950f25c8da789d1b78b25e7e74786d7cff6ff98f941
MD5 6bce737f56a15d70eea196ec8c82e6df
BLAKE2b-256 00d67cb2f79e5c180afd6312f2edae66b00bd9f4bb1f928489cb78324e2291a0

See more details on using hashes here.

Supported by

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