Skip to content

Instantly share code, notes, and snippets.

@pystardust
Last active November 6, 2021 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pystardust/e7abf60b1580a144f9516bd33290c88c to your computer and use it in GitHub Desktop.
Save pystardust/e7abf60b1580a144f9516bd33290c88c to your computer and use it in GitHub Desktop.
random domain names
#!/bin/bash
# Generating random domain names
temp_file=`mktemp`
get_word() {
word=$(
xidel -s https://www.thisworddoesnotexist.com/ --css "#definition-word"
)
if (( ${#word} < 8 )); then
word=$(sed 's/[^a-z A-Z]//g;s/$/.com/' <<< "$word")
flock "$temp_file" printf '%s\n' "$word" >> "$temp_file"
fi
printf '.'
}
export temp_file
export -f get_word
for (( i=0 ; i<100 ; i++)); do
sem -j 20 "get_word"
done
sem --wait
printf '\n'
readarray -t domains < "$temp_file"
rm "$temp_file"
printf '%s\n' "${domains[@]}"
printf 'found %d names\n' "${#domains[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment