Skip to content

Instantly share code, notes, and snippets.

@tzi
Last active Apr 16, 2019
Embed
What would you like to do?
Check host availability from an HTML page

Check domains

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment