primer commit
This commit is contained in:
commit
5b01175a64
5
LICENSE
Normal file
5
LICENSE
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
"THE NON-ALCOHOLIC-BEVERAGE-WARE LICENSE":
|
||||||
|
|
||||||
|
<xaloc@tutanota.com> wrote this. As long as you retain this notice you can
|
||||||
|
do whatever you want with this stuff. If we meet some day, and you think this
|
||||||
|
stuff is worth it, you can buy me a non-alcoholic beverage in return Xaloc
|
10
README.md
Normal file
10
README.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Estimar la mida d'una pàgina web
|
||||||
|
Aquest escript de bash utilitza wget, grep i awk per estimar la mida d'una pàgina web. El script agafa tot el que hi ha al primer nivell de la pàgina però no mira recursivament cap més nivell.
|
||||||
|
|
||||||
|
Aquest escript ha estat fortament inspirat d'[aquest repositori](https://github.com/izkreny/website-size)
|
||||||
|
|
||||||
|
## Utilització
|
||||||
|
1. Còpia o baixa el script
|
||||||
|
1. Dona-li permisos d'execució `chmod +x website-size.sh`
|
||||||
|
1. Executa'l amb la pàgina que vulguis utilitzar com a argument `./website-size.sh example.org`
|
||||||
|
|
30
website-size.sh
Executable file
30
website-size.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
output="/tmp/website-size.out"
|
||||||
|
echo "Analitzant ${!#}..."
|
||||||
|
sleep 1s
|
||||||
|
echo "Pot tardar una estona..."
|
||||||
|
|
||||||
|
wget \
|
||||||
|
--recursive --level=1 \
|
||||||
|
--spider --server-response \
|
||||||
|
--no-directories --no-parent \
|
||||||
|
--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
|
Loading…
Reference in New Issue
Block a user