This script check domains availability of links from an HTML file 🎉
# Usage
$ ./check-domains.sh ./bookmarks.html
aslibrary.org is available| #!/bin/bash | |
| if [ $# -gt 0 ]; | |
| then | |
| input=$1; | |
| else | |
| echo "Usage: $0 <file.html>"; | |
| echo ; | |
| exit 1 | |
| fi | |
| # Extract urls from HTML file | |
| urls=$(mech-dump --links "$input") | |
| # Extract domains from urls | |
| domains=$(cut -d"/" -f3 <<<"$urls"| rev | cut -d"." -f-2 | rev | sort | uniq); | |
| # For each domain check availability | |
| for domain in $domains; | |
| do | |
| # Check for a server ping | |
| host "$domain" | grep "NXDOMAIN" >&/dev/null; | |
| if [ $? -eq 1 ] | |
| then | |
| continue | |
| fi | |
| # Check on whois registry | |
| whois "$domain" | grep -E "(No match for|NOT FOUND)" >&/dev/null; | |
| if [ $? -eq 1 ] | |
| then | |
| continue | |
| fi | |
| echo "$domain is available"; | |
| done |