URL Tracker
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:
- Single URL status checking
- Batch URL processing from a file
- Redirect chain tracking
- CSV output for further analysis
- Basic authentication support
- Custom headers and cookies
Prerequisites
- Bash shell environment
curl
command-line toolBATS
(Bash Automated Testing System) for running tests
Installation
Via Homebrew
brew tap nalmeida/urltracker
brew install urltracker
Via git clone
- Clone this repository:
git clone https://github.com/nalmeida/urltracker.git
cd urltracker
- Make the script executable:
chmod +x urltracker
- (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:
- Install BATS if you don't have it:
# MacOS
brew install bats-core
# Debian/Ubuntu
sudo apt-get install bats
- Run the tests:
bats test_urltracker.bats
- For verbose test output:
bats --tap test_urltracker.bats
- For debug test output:
bats --print-output-on-failure --show-output-of-passing-tests test_urltracker.bats
Test Coverage
The test suite covers:
- Basic functionality
- URL list processing
- Output formatting
- Error handling
- Authentication and custom headers
- Command-line option parsing
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Make your changes and add tests for new functionality
- Run the test suite to ensure everything passes (
bats test_urltracker.bats
) - Commit your changes (
git commit -am 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Create a new Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- The BATS project for the testing framework
- The command
curl -IL https://httpbin.org/redirect/2
that led me to create this project - The amazing httpx as inspiration and a powerful alternative to this humble project
- The amazing vhs CLI demo generator