A simple URL validity checker
Project description
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. ❤️🎈
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
File details
Details for the file validlink-0.2.tar.gz
.
File metadata
- Download URL: validlink-0.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b83b668601765cc6384dbbdc699846e2c22d692e8d7286daeb2b6fd75544e61e |
|
MD5 | 2099dc2eeacb73cdf968ff7c7962cfd4 |
|
BLAKE2b-256 | bbfa54a85607cfc5f3a674701e5be93781f42ec286a3ccf2ac783846b2f853fe |
File details
Details for the file validlink-0.2-py3-none-any.whl
.
File metadata
- Download URL: validlink-0.2-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f779563b7d736c9b5518632d9611838df9f046f94a27c526e00815d80224826 |
|
MD5 | 62dda31074e0e83504025e47b791dbbd |
|
BLAKE2b-256 | f9d20788bb387f0e3c5304c678f63ef60f5b4171d236273fabecfdf395205e74 |