Skip to content

Checks for broken links and images within a specified domain. It crawls through the website's HTML content, identifies all the links and images, and checks the status codes for each of them. The script then displays a list of broken links and external or broken images found on the website.

License

Notifications You must be signed in to change notification settings

donaldafeith/Python-Broken-Link-Check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Broken Links and Images Checker

This Python script checks for broken links and images within a specified domain. It crawls through the website's HTML content, identifies all the links and images, and checks the status codes for each of them. The script then displays a list of broken links and external or broken images found on the website.

Features

  • Checks for broken internal links on the website
  • Checks for broken or external images on the website
  • Ignores SVG images and relative URLs starting with /public/
  • Displays progress while checking links and images
  • Handles connection errors gracefully

Author

This script was created by Donalda.

Requirements

  • Python 3.x
  • requests library
  • beautifulsoup4 library

Setup

It's recommended to use a virtual environment to install the required packages and run the script. Here's how you can set up a virtual environment:

  1. Open a terminal or command prompt and navigate to the directory where you want to create the virtual environment.

  2. Create a new virtual environment using the following command:

python -m venv linkcheck

This will create a new directory called linkcheck containing the virtual environment.

  1. Activate the virtual environment:
  • On Windows:

    linkcheck\Scripts\activate
    
  • On Unix or macOS:

    source linkcheck/bin/activate
    

You should see (linkcheck) at the beginning of your command prompt, indicating that the virtual environment is activated.

  1. Install the required libraries by running:
pip install -r requirements.txt

This will install the requests and beautifulsoup4 libraries in the virtual environment.

Usage

  1. Open a terminal or command prompt and navigate to the directory containing the script.
  2. Ensure that the virtual environment is activated ((linkcheck) should be visible in your command prompt).
  3. Run the script using the following command:
python broken_links_checker.py
  1. When prompted, enter the domain name you want to check (e.g., example.com).
  2. The script will start checking for broken links and images on the specified domain and display the progress.
  3. Once the check is complete, the script will display a list of broken links and broken or external images found on the website, if any.

Example Output

Checking links and images... 100.00% - Currently checking: https://example.com/images/logo.png

Broken links and images found on example.com:
Broken links:
https://example.com/broken-link
Broken or external images:
https://external-image.com/image.jpg

License

This script is released under the MIT License.

About

Checks for broken links and images within a specified domain. It crawls through the website's HTML content, identifies all the links and images, and checks the status codes for each of them. The script then displays a list of broken links and external or broken images found on the website.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages