Skip to content

A super simple Python utility to check for dead links in a website.

License

Notifications You must be signed in to change notification settings

georgeholt1/pylich

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyLich

GitHub Actions Workflow Status PyPI - Version PyPI - Python Version GitHub License

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.
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

About

A super simple Python utility to check for dead links in a website.

Resources

License

Stars

Watchers

Forks

Languages