Awk : calcul la taille d'une page html
Ce script vous donnera la taille totale d'une page html en tenant compte des images, des scripts et des feuilles de style inclus.C'est très facile à utiliser, il suffit de taper le nom du script suivi du nom du fichier html
#!/bin/awk -f
BEGIN {
RS="<"
}
# <IMG SRC ...
/^(I|i)(m|M)(g|G) .*(s|S)(r|R)(C|c)/ {
sub(/^(I|i)(m|M)(g|G) .*(s|S)(r|R)(C|c) *="?/,"",$0)
match($0,/[^" ]+("| )?/)
image = substr($0,RSTART,RLENGTH-1)
if ( image ~ /^http/ )
next
if ( length(image ) < 5 )
next
images[image]=1
next
}
# <SCRIPT SRC...
/^(s|S)(C|c)(r|R)(I|i)(P|p)(T|t) .*(s|S)(r|R)(C|c)/ {
sub(/^(s|S)(C|c)(r|R)(I|i)(P|p)(T|t) .*(s|S)(r|R)(C|c) *="?/,"",$0)
match($0,/[^" ]+("| )?/)
image = substr($0,RSTART,RLENGTH-1)
if ( image ~ /^http/ )
next
if ( length(image ) < 2 )
next
images[image]=1
next
}
#CSS
/^(L|l)(I|i)(N|n)(K|k) .*(H|h)(r|R)(E|e)(F|f)/ {
sub(/^(L|l)(I|i)(N|n)(K|k) .*(H|h)(r|R)(E|e)(F|f) *="?/,"",$0)
match($0,/[^" ]+("| )?/)
image = substr($0,RSTART,RLENGTH-1)
if ( image ~ /^http/ )
next
if ( length(image ) < 2 )
next
images[image]=1
next
}
END {
total=0
images[FILENAME]=1
for ( i in images )
{
command = "wc -c "i
command | getline
print i " " $1
total += $1
}
print "_______________"
print "total = "total
}
Awk : calcul la taille d'une page html : micro annuaire
| cygwin | : | le compilateur gcc sous windows ainsi que tous les outils unix (awk, grep, sed, bash, ksh ...). |
| Youhp3 | : | Youpee est un preprocesseur HTML pour vous simplifier toutes les tâches répétitives dans la création d'un site web. Salemioche.net utilise trés largement ses possibilités. |
