A super simple Python utility to check for dead links in a website
Project description
PyLich
A super simple Python utility to check for dead links in a website.
Installation
PyLich is available on PyPI and can be installed using pip:
pip install pylich
Usage
Simply provide the URL of the sitemap and pylich will crawl through links in the pages and check their status. pylich can be used as a command line tool or as a Python package.
Command Line
pylich https://www.example.com/sitemap.xml
The command will exit with a status code of 1 if any dead links are found and 0 otherwise.
Options
| Flag | Arguments | Description |
|---|---|---|
-v |
N/A | Verbose mode. Print progress to the console as well as a summary of the dead links at the end. |
-i |
List of integer HTTP response codes | Ignore links with the specified HTTP response codes. |
--failed-is-dead |
N/A | Treat any failed HTTP request as a dead link, regardless of the HTTP status code. |
pylich https://www.example.com/sitemap.xml -v -i 404 500
Python Package
PyLich can also be used as a Python package.
from pylich import LinkChecker
checker = LinkChecker(
"https://www.example.com/sitemap.xml",
verbose=True,
ignored_status_codes=[404, 500]
)
urls = checker.get_sitemap_urls()
broken_links = checker.check_links(urls)
checker.print_dead_links()
Contributing
Pull requests are welcome.
Package and dependency management is done using Poetry. To install the dependencies and the package in development mode, run:
poetry install
To run the tests, run:
pytest
Pre-commit hooks are available to run code formatting and linting. To install the hooks, run:
pre-commit install
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylich-0.4.0.tar.gz.
File metadata
- Download URL: pylich-0.4.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.8 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adafea1bba070d9a15c5209c56d9a5c43049fbfda1f46966bae670e590bb42da
|
|
| MD5 |
e69963518ae92c6e554d7b23e127ab54
|
|
| BLAKE2b-256 |
f9b22afe390a338d46f1c690c79afd61f1e75338346560ba6e54627a63e55fb5
|
File details
Details for the file pylich-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pylich-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.8 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce608590b17a36802ec8e31c4862fc9ff48d88ba954257d584fa727681b390a3
|
|
| MD5 |
d4211efe6b7845b146587bda8a22ace8
|
|
| BLAKE2b-256 |
3187e279e12540639c5a01158d97efe8f9866b97625f777d3bc055bf05cf173b
|