#!/bin/bash
# Input file with list of domain names, one per line
# sudo apt get parallel
# Function to get the title of a webpage using curl and grep
get_title() {
local domain=$1
local title=$(curl -s "https://$domain" | grep -oP '(?<=
).*(?=)')
echo "$domain,$title"
}
# Bash functions: export -f the function first or use env_parallel.
#export -f get_title otherwise wont recognize the function
export -f get_title
# Use parallel to process the input file and call the get_title function
parallel --timeout 300% --load 90% --bar -a sort_u_domains.txt get_title >> faster_candy.txt
#timeout of 300% of average, only us 90% system resource, show progress bar, -a is the input file of arguments = the_domain, call get title and output append to faster_candy.txt