URL Tracker

urltracker demo

A command-line tool to check HTTP status codes and track redirections for URLs.

Github repo: https://github.com/nalmeida/urltracker

Overview

URL Tracker helps you analyze HTTP responses and redirects for single URLs or lists of URLs. Perfect for website maintenance, SEO auditing, and link checking.

Features:

Prerequisites

Installation

Via Homebrew

brew tap nalmeida/urltracker
brew install urltracker

Via git clone

  1. Clone this repository:
git clone https://github.com/nalmeida/urltracker.git
cd urltracker
  1. Make the script executable:
chmod +x urltracker
  1. (Optional) Create a symlink to use it from anywhere:
sudo ln -s $(pwd)/urltracker /usr/local/bin/urltracker

Usage

Basic URL Check

urltracker https://httpbin.org/status/200

Process a List of URLs

Create a text file with one URL per line:

https://httpbin.org/status/200
https://httpbin.org/redirect/2
https://httpbin.org/status/404

Then run:

urltracker --list urls.txt

Output to CSV

urltracker --list urls.txt --output results.csv

Using Authentication

urltracker --auth user:pass https://httpbin.org/basic-auth/user/pass

Using Custom Headers

urltracker --header "User-Agent: Mozilla/5.0" --header "Accept-Language: en-US" https://httpbin.org/status/200

Verbose Output

urltracker --verbose https://httpbin.org/redirect/2

Full Options List

Usage: urltracker [OPTIONS] [URL]

Options:
  -h, --help           Display this help message
  -V, --version        Display the version
  -l, --list <file>    Process a list of URLs from a text file
  -o, --output <file>  Export results to a CSV file
  -v, --verbose        Verbose mode: show all redirect URLs
  -q, --quiet          Quiet mode: no output to console
  -nc, --no-color      Disable colored output
  -a, --auth <user:password>   Use HTTP Basic Authentication
  -H, --header <header>        Add custom header (can be used multiple times)
  -c, --cookie <name=value>    Add a cookie (can be used multiple times)

Development

Running Tests

This project uses BATS (Bash Automated Testing System) for testing. To run the tests:

  1. Install BATS if you don't have it:
# MacOS
brew install bats-core

# Debian/Ubuntu
sudo apt-get install bats
  1. Run the tests:
bats test_urltracker.bats
  1. For verbose test output:
bats --tap test_urltracker.bats
  1. For debug test output:
bats --print-output-on-failure --show-output-of-passing-tests test_urltracker.bats

Test Coverage

The test suite covers:

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes and add tests for new functionality
  4. Run the test suite to ensure everything passes (bats test_urltracker.bats)
  5. Commit your changes (git commit -am 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Create a new Pull Request

License

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

Acknowledgments