Hello à tous,
Je suis noveau sur le forum et encore plus dans le monde PERL. J'ai une petite tache qui ma été assigné et il faut bien avouer, je sèche un peu.
Je voudrais depuis un fichier html extraire les "href" pour ne garder que
host.domain.xx - J'ai trouvé sur un site un script bien et je l'ai qq peu modifié:
-----------------------
# exturls.pl
-----------------------
while (<>) {
$src .= $_
} ;
$_ = $src ;
while (m|href="http://(.*?)"|gs) {
my $url=$1;
print "$url\n";
} ;
-----------------------
Par exemple, si je prends la page index.html du site http://www.icq.com et que je lance la commande suivante, j'obtiens:
# perl exturls.pl index.html
[...]
games.icq.com/game.htm?code=110356410&RefId=MagicBall2_441x206
entertainment.icq.com
romance.icq.com
people.icq.com/
company.icq.com/info/advertise.html
company.icq.com/info/contact.html
company.icq.com/
company.icq.com/info/icqstory.html
www.icq.com/products/sitemap.html
www.icq.com/legal/privacy.html
www.icq.com/legal/
Je voudrais arriver à ne garder que www.icq.com ou people.icq.com et tronquer le reste de la chaine pour ensuite, ne les afficher qu'une seule fois chacune.
Auriez-vous une idée pour m'aider?
Merci par avance
M
Partager