A smart URL redirect checker that traces redirect chains with intelligent logging.
- π Traces complete redirect chains
- π Smart logging to both console and files
- π Detects redirect loops
- π Generates JSON reports for detailed analysis
- π Tracks unique domains visited
- β±οΈ Measures redirect chain duration
- π‘οΈ Handles various redirect types (301, 302, 303, 307, 308)
pip install -r requirements.txtpython redirect_checker.py "https://example.com/redirect"from redirect_checker import RedirectChecker
checker = RedirectChecker(log_dir="logs")
result = checker.check_redirects("https://example.com/redirect")
if result['success']:
print(f"Found {result['redirect_count']} redirects")
print(f"Final destination: {result['chain'][-1]['url']}")The tool generates two types of logs in the logs/ directory:
-
Text Log (
redirect_check_YYYYMMDD_HHMMSS.log)- Human-readable log with timestamps
- Shows each redirect step
- Includes response headers
- Summary statistics
-
JSON Report (
redirect_chain_<hash>_YYYYMMDD_HHMMSS.json)- Machine-readable format
- Complete redirect chain data
- All response headers
- Duration metrics
2026-01-14 12:00:00 - INFO - Starting redirect check...
2026-01-14 12:00:00 - INFO - Initial URL domain: rt.pornhub.com
2026-01-14 12:00:01 - INFO - β Redirecting to: https://track.llinkosec.com/...
2026-01-14 12:00:02 - INFO - β Final destination reached
2026-01-14 12:00:02 - INFO - Total Redirects: 3
You can customize the behavior:
max_redirects: Maximum redirects to follow (default: 20)timeout: Request timeout in seconds (default: 10)log_dir: Directory for logs (default: "logs")