Skip to main content

ValidLink

A simple Python library to check the validity of URLs.

Features

  • Check the validity of a given URL.
  • Automatically add missing schemes (e.g., http://).
  • Handle URLs without common subdomains like www..
  • Graceful error handling for various request exceptions.

Installation

pip install validlink

Usage

Basic Usage

from validlink import check_url_validity

url = "https://www.example.com"
is_valid = check_url_validity(url)
if is_valid:
    print(f"The URL {url} is valid.")
else:
    print(f"The URL {url} is not valid.")

Handling Different URL Formats

from validlink import check_url_validity

urls = [
    "example.com",
    "http://example.com",
    "https://example.com",
    "www.example.com",
    "example.com/test",
]

for url in urls:
    is_valid = check_url_validity(url)
    if is_valid:
        print(f"The URL {url} is valid.")
    else:
        print(f"The URL {url} is not valid.")

Extracting URLs from Messages

from validlink import find_urls_in_message, check_url_validity

messages = [
    "your message Eid code good https://www.example.com thank you god",
    "your message Eid code good example.com thank you god",
]

for message in messages:
    urls = find_urls_in_message(message)
    for url in urls:
        is_valid = check_url_validity(url)
        if is_valid:
            print(f"The URL {url} found in the message is valid.")
        else:
            print(f"The URL {url} found in the message is not valid.")

Checking URLs from User Input

from validlink import check_url_validity

url = input("Enter a URL to check: ")
is_valid = check_url_validity(url)
if is_valid:
    print(f"The URL {url} is valid.")
else:
    print(f"The URL {url} is not valid.")

Handling URLs in Web Scraping

import requests
from validlink import check_url_validity

# Assume urls_list contains a list of URLs obtained from web scraping
urls_list = ["https://www.example.com", "http://example.com", "www.example.com"]

for url in urls_list:
    is_valid = check_url_validity(url)
    if is_valid:
        print(f"The URL {url} is valid.")
    else:
        print(f"The URL {url} is not valid.")

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Acknowledgements

Special thanks to all the contributors of open-source libraries that made this project possible.

Thank You

Thank you to all users who have found this tool helpful! Your support and feedback are greatly appreciated. ❤️🎈

Download files

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

Source Distribution

validlink-0.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

validlink-0.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

Release history Release notifications | RSS feed

This release

0.2 This release

2 files

0.1

2 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