midaWeb/website-size.sh

32 lines
608 B
Bash
Raw Normal View History

2024-01-17 20:40:34 +00:00
#!/bin/bash
2024-01-18 13:37:17 +00:00
output="./${!#}.log"
2024-01-17 20:40:34 +00:00
echo "Analitzant ${!#}..."
sleep 1s
echo "Pot tardar una estona..."
wget \
--recursive --level=1 \
--spider --server-response \
--no-directories --no-parent \
2024-01-18 13:37:17 +00:00
-e robots=off \
2024-01-17 20:40:34 +00:00
--output-file="$output" "$@"
sleep 1s
if [ -f "$output" ]
then
# Calculate and print estimated website size
echo "Mida estimada de ${!#}: $(\
grep -e "Content-Length" "$output" | \
awk '{sum+=$2} END {printf("%.0f", sum / 1024)}'\
) kb"
# Delete wget output file
rm "$output"
else
echo "Unable to calculate estimated size."
exit 1
fi
exit 0