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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

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