1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| #!C:\Perl\bin\perl.exe
$| = 1;
##################################
# Tableau d'adresse(s)
##################################
@site = ("http://www.google.com/robots.txt","http://www.clubic.com/robots.txt");
##################################
# Appelle des fonctions
##################################
@site = find(@site);
@site = replace(@site);
##################################
# Recherche des robots.txt
##################################
sub find
{
use LWP::Simple;
my @resultat;
for my $url( @_ ) {
push @resultat, get($url);
}
return @resultat;
@_ = ();
@resultat = ();
}
##################################
# Parser robots.txt
##################################
sub replace
{
foreach $_ (@_) {
@parse = split /\n$/, $_;
$parse[0] =~ s/User-agent: \*//ig;
$parse[0] =~ s/Allow.*//g;
$X =~ s/\/robots\.txt//ig;
$parse[0] =~ s/Disallow: /$X\/$1/ig;
$parse[0] =~ s/\/\//\//ig;
$parse[0] =~ s/http:\//http:\/\//ig;
$parse[0] =~ s/^\n*//ig;
$parse[0] =~ s/\n$//ig;
print "$parse[0]"; # C'est ici que l'on doit récupére les données
}
} |
Partager