#!/bin/bash
rm -f "$2/tableau.html" ;
echo "Les urls SONT DANS : $1" ;
echo "On créé le tableau HTML dans : $2" ;
echo "
" >> "$2/tableau.html" ;
echo "N° | URL | Code http | encodage | Page aspirée | Dump | Filtrage Txt | Filtrage Html | Index | Bitexte | Fq Motif |
" >> "$2/tableau.html" ;
for ligne in $(cat "$1/$fichier")
do
echo "----------------------------------------------";
echo "Traitement de l'URL : $ligne";
echo "----------------------------------------------";
coderetourhttp=$(curl -SIL -o tmp.txt -w %{http_code} $ligne);
echo "CODE HTTP : $coderetourhttp";
if [[ $coderetourhttp == 200 ]]
then
encodage=$(curl -sIL -o toto -w %{content_type} $ligne | cut -f2 -d"=" | tr '[a-z]' '[A-Z]' | tr -d '\r');
echo "ENCODAGE DETECTE PAR CURL : $encodage";
curl -L -o "./PAGES-ASPIREES/$numerotableau-$compteur.html" "$ligne";
if [[ $encodage == "UTF-8" ]]
then
lynx -dump -nolist -assume_charset=$encodage -display_charset=$encodage "./PAGES-ASPIREES/$numerotableau-$compteur.html" > ./DUMP-TEXT/$numerotableau-$compteur.txt;
egrep -i -C2 "$motif" ./DUMP-TEXT/$numerotableau-$compteur.txt > ./CONTEXTES/$numerotableau-$compteur.txt;
nbmotif=$(egrep -coi "$motif" ./DUMP-TEXT/$numerotableau-$compteur.txt;);
perl ./minigrep/minigrepmultilingue.pl "utf-8" ./DUMP-TEXT/$numerotableau-$compteur.txt ./minigrep/parametre-motif.txt ;
mv resultat-extraction.html ./CONTEXTES/$numerotableau-$compteur.html ;
egrep -o "\w+" ./DUMP-TEXT/$numerotableau-$compteur.txt | sort | uniq -c | sort -r > ./DUMP-TEXT/index-$numerotableau-$compteur.txt ;
egrep -o "\w+" ./DUMP-TEXT/$numerotableau-$compteur.txt > bi1.txt;
tail -n +2 bi1.txt > bi2.txt ;
paste bi1.txt bi2.txt > bi3.txt ;
cat bi3.txt | sort | uniq -c | sort -r > ./DUMP-TEXT/bigramme-$numerotableau-$compteur.txt ;
cat ./DUMP-TEXT/bigramme-$numerotableau-$compteur.txt >> concatenate1.txt;
echo ~~ >> concatenate1.txt;
cat ./CONTEXTES/bigramme-$numerotableau-$compteur.txt >> concatenate2.txt;
echo ~~ >> concatenate2.txt;
echo "
$compteur |
$ligne |
Code_http:$coderetourhttp |
Encodage:$encodage |
$numerotableau-$compteur.html |
$numerotableau-$compteur.txt |
$numerotableau-$compteur.txt |
$numerotableau-$compteur.html |
index-$numerotableau-$compteur |
bigramme-$numerotableau-$compteur |
$nbmotif |
" >> "$2/tableau.html";
else
echo "$compteur | $ligne | Code_http:$coderetourhttp | Encodage:$encodage | $numerotableau-$compteur.html | - | - | - | - | - | - |
" >> "$2/tableau.html";
fi
else
echo "$compteur | $ligne | Code_http:$coderetourhttp | - | - | - | - | - | - | - | - |
" >> "$2/tableau.html";
fi
compteur=$((compteur+1)) ;
done
echo "