IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Perl Discussion :

[langage] Moteur de recherche


Sujet :

Langage Perl

  1. #1
    Membre actif Avatar de mobscene
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    331
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 331
    Points : 234
    Points
    234
    Par défaut [langage] Moteur de recherche
    Je cherche depuis quelque temps a faire un ti robot mais assez complet pour mon/mes futur site(s) web , j'ai trouver sur le forum un robot mais qui marche avec un connection socket bref pas du tout ce qu'il me faut. J'ai trouvé ce script.
    Je vais faire un site qui seras un annuaire de lien de tout les sites touchant au modélise

    Il faut donc que le robot puisse ce balader sur le net comme le robot google par exempl.

    Je voudrais donc savoir qu'elle sont les possibilité rélle de ce robot, car chez moi perl me dit

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Erreur CGI
    L'application CGI spécifiée n'a pas renvoyé le jeu complet d'en-têtes HTTP.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    58
    59
    60
    61
    62
    63
    64
    #!/usr/bin/perl -w
    use strict;
     
    my $VERSION = "0.82";
     
    use LWP::UserAgent;
    use HTML::LinkExtor;
    use URI::URL;
     
    $| = 1;
     
    sub spider (%);
     
    spider URL => '$url';
     
    sub spider (%) {
    	my %args = @_;
     
    	my @startlinks = ();
     
    	push(@startlinks, $args{URL});
     
    	my $ua = LWP::UserAgent->new;
     
    	WORKLOOP: while (my $link = shift @startlinks) {
     
    		for (my $i = 0; $i< $#startlinks; $i++) {
    			next WORKLOOP if $link eq $startlinks[$i];
    		}
    		print ">>>>> working on $link\n";
    	        HTML::LinkExtor->new(
              	  sub {
    			my ($t, %a) = @_;
    			my @links = map { url($_, $link)->abs() }
    			grep { defined } @a{qw/href img/};
     
    			# mark already spidered links for removal
    			foreach my $start_link (@startlinks) {
    				my $i = 0;
    				for (0 .. $#links) {
    					if ($links[$i++] eq $start_link) {
    						$links[$i -1] = "'REMOVE'";
    					}
    				}
    			}
     
    			@links = sort @links;
    			for (my $i = 0; $i< $#links; $i++) {
    				$links[$i] = "'REMOVE'" if $links[$i] eq $links[$i +1];
    			}
    			@links = grep { $_ ne "'REMOVE'" } @links;
     
    			print "+ $_\n" foreach @links;
     
    			push @startlinks, @links if @links;
              	  } ) -> parse(
               	  do {
                   		my $r = $ua->simple_request
                     	(HTTP::Request->new("GET", $link));
                   		$r->content_type eq "text/html" ? $r->content : "";
               	  }
             	)
    	}
    }
    Voila un no uveau threads tu beau tout neuf

  2. #2
    Membre actif Avatar de mobscene
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    331
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 331
    Points : 234
    Points
    234
    Par défaut
    Voila ont repart sur de bonne base :
    Voci quelque fonction que je vais ajouter (glaner sur le forum).


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    ################################################################ 
    # Suppréssion des liens bannies (c) Jedai 
    ################################################################ 
     
           sub bannie 
           { 
     
           { 
           my %temp; 
           @temp{@links} = (1) x @links; 
           @temp{@bannie} = (0) x @bannie; 
           @links = grep { $temp{$_} } @links; 
           } 
           $, = ", "; 
           # print @e; 
     
           return @links;        
     
           } 
     
     
     
     
     
     
     
    ################################################################### 
    # Suppéssion des doublons (c) nematoad 
    ################################################################### 
     
             sub Array_Unique 
             { 
             my %vu; 
             ++$vu{$_} for @_; 
             (keys %vu); 
             }


    Si j'arrive a mettre ce robot au point je le balance sur sourceforge

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    73
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 73
    Points : 49
    Points
    49
    Par défaut
    Je voie que tu a suivie mon conseille (sa partais vraiment partout).

    Je pense le fonctionnement de ton robot comme suit :



    -> Connection a mysql et récupération des liens déjà indexer et de leur date d'indexation-


    -> Quand il arrive sur un site il cherche en premier le fichier robots.txt
    -> Ajustement des liens de robots.txt



    -> Parcour toute les page a la recherche des liens et <img
    -> Suppréssion des liens bannies
    -> Suppréssion des doublons
    -> Suppréssion des liens interdits (robots.txt)


    -> Comparaison avec les pages déjà indexer
    -> Si indexer il a a plus de 30J alors ont met a jour
    -> Sinon ont le supprime



    -> Trie des liens interne et externe
    -> Déplacement des liens externe dans un autre tableau
    -> Get sur toutes les pages (interne)
    -> Une fois le get effectué ont déplace les liens dans @already_spider



    -> Le robot refait une boucle avec les liens externes (ou un deuxième threds)


    Voila comme sa tu a ton schéma de fonctionnement
    Je vais essayer de faire le script pour robots.txt

    Sur sourceforge ce serais pas mal parce qu'il n'y a pas beaucoup de projet perl , un genre de Nutch mais perl faudrais voire avec les expert comme Gldavid ou Djibril je pense que c'est une super bonne idée

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    73
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 73
    Points : 49
    Points
    49
    Par défaut
    Je vient de penser a une chose comment dans un tableau @url recherche si les url ce finisse pas / sinon ont l'ajoute

    Je m'explique

    Si ont ne fait pas de vérification le robot pourrais faire http://www.free.fr.robots.txt ce qui est faux

    Je ne sais pas comment fair ! Merci pour vos suggestions a ce propos

  5. #5
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 820
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 498 771
    Points
    498 771
    Par défaut
    voila comment rajouter un / à tes urls si necessaire.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    foreach my $ajout (@url) {
    $ajout .= "\/" unless ($ajout =~ /\/$/);
    }

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    73
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 73
    Points : 49
    Points
    49
    Par défaut
    Merci Djibril

    Voic le morceau de script pour détecter un fichier robots.txt , mais j'ai un résultat suprenant

    HTTP::RequestHASH(0x1ad174c)
    si je fait

    print "@request\n";
    ou
    print "$response\n";
    Je ne trouve pas de solution a sa

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    #!/usr/local/bin/perl
     
    require HTTP::Request;
           require LWP::UserAgent;
     
    $ua = new LWP::UserAgent;
    $ua->timeout(8);
    $ua->max_size(400);
     
     
    @url = ("http://www.google.com/robots.txt");
     
     
     
    @request = new HTTP::Request GET => @url;
    $response = $ua->request(@request);
    if ($response->is_success)
       {
     
     
       print  "Un fichier robots.txt";
     
     
     
       }
     
       else { print "No"; }
    Sur le CPAN j'ai trouver ceci qui est parfaitement fonctionelle , je vais donc pouvoir finir mon script.



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    use WWW::RobotRules;
     my $rules = WWW::RobotRules->new('MOMspider/1.0');
     
     use LWP::Simple qw(get);
     
     {
       my $url = "http://some.place/robots.txt";
       my $robots_txt = get $url;
       $rules->parse($url, $robots_txt) if defined $robots_txt;
     }
     
     {
       my $url = "http://some.other.place/robots.txt";
       my $robots_txt = get $url;
       $rules->parse($url, $robots_txt) if defined $robots_txt;
     }
     
     # Now we can check if a URL is valid for those servers
     # whose "robots.txt" files we've gotten and parsed:
     if($rules->allowed($url)) {
         $c = get $url;
         ...
     }

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    73
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 73
    Points : 49
    Points
    49
    Par défaut
    Pour tester WWW::Robotrules

    J'ai taper le script suivant qui me retourne pas les dossier que je peut spider ?



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    #!/usr/bin/perl
    use strict;
     
     &robots;
     
     my @X = ("http://www.google.com/robots.txt","http://www.free.fr/robots.txt");
     
       sub robots
       {
     
       use WWW::RobotRules;
       my $rules = WWW::RobotRules->new('MOMspider/1.0');
     
       use LWP::Simple qw(get);
     
       {
        my @url = "@X";
        my $robots_txt = get @url;
        $rules->parse(@url, $robots_txt) if defined $robots_txt;
      }
     
      {
        my @url = "@X";
        my $robots_txt = get @url;
        $rules->parse(@url, $robots_txt) if defined $robots_txt;
      }
     
      # Now we can check if a URL is valid for those servers
      # whose "robots.txt" files we've gotten and parsed:
      # $c = get @url;
      if($rules->allowed(@url)) {
     
        print "Yo sa marche";
     
     
       } else { print " Pas de fichier robots.txt"; }
     
     
     
      }
    Mais sa marche très bien comme ceci




    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    sub robots
       {
     
       use WWW::RobotRules;
       my $rules = WWW::RobotRules->new('MOMspider/1.0');
     
       use LWP::Simple qw(get);
     
       {
        my $url = "http://google.com/robots.txt";
        my $robots_txt = get $url;
        $rules->parse($url, $robots_txt) if defined $robots_txt;
      }
     
      {
        my $url = "http://google.com/robots.txt";
        my $robots_txt = get $url;
        $rules->parse($url, $robots_txt) if defined $robots_txt;
      }
     
      # Now we can check if a URL is valid for those servers
      # whose "robots.txt" files we've gotten and parsed:
      # $c = get $url;
      if($rules->allowed($url)) {
     
        print "Yo sa marche cette crote";
     
     
       } else { $statut = "continue"; }
     
     
     
       }

  8. #8
    Membre actif Avatar de mobscene
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    331
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 331
    Points : 234
    Points
    234
    Par défaut
    Voila ce que j'ai fait , ces't loin d'être fini donc si vous voyez des fautes merci de me les signaler, il manque le robot en lui même que je ferais lus tard il s'agit la d'une partie des sous programme qu'il utiliseras, j'ai le même problème que Siaoy avec WWW::Robotrules avec les tableau.

    Experimental vive les bugs a corriger après lol

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    #!/usr/bin/perl -w
    use strict;
    use warnings;
     
    require "config.pl";
     
    ###################################################################
    # Lancement du programme
    ###################################################################
     
       my $bannie = "/spider/ignore_list.txt";
     
       my $links = "/spider/liste_url.txt";
     
       my $already = "/spider/already_spidering.txt";
     
       my @bannie = lire_fichier($bannie);
     
       my @links = lire_fichier($links);
     
       my @already = lire_fichier($already);
     
       my $date=&afficher_date;
     
     
     
     
     
     
    ###################################################################
    # Ouverture des fichiers prédéfinit
    ###################################################################
     
     
        sub lire_fichier 
        { 
        my ($fichier) = @_ ; 
     
        open FICHIER, $fichier || die "Unable to open $fichier: $!"; 
        @tab_result = <FICHIER>; 
        close FICHIER; 
        chomp @tab_result; 
     
     
         return @tab_result; 
        } 
     
     
     
    ###################################################################
    # Suppréssion des liens bannis
    ###################################################################
     
     
           sub bannie
           {
     
           { 
           my %temp; 
           @temp{@links} = (1) x @links; 
           @temp{@bannie} = (0) x @bannie; 
           @links = grep { $temp{$_} } @links; 
           } 
           $, = ", "; 
           # print @e;
     
           return @links;       
     
           }
     
     
     
    ###################################################################
    # Suppréssion des doublons
    ###################################################################
     
     
     
             @links = Array_Unique(@links);
     
     
    ###################################################################
    # Préparation du tableau de site
    ###################################################################
     
     
        sub slash
        {
     
        foreach my $ajout (@url) { 
        $ajout .= "\/" unless ($ajout =~ /\/$/); 
        }
     
        return @url;
     
        }
     
     
    ###################################################################
    # Repérage de robots.txt
    ###################################################################
     
     
       sub robots
       {
     
       use WWW::RobotRules;
       my $rules = WWW::RobotRules->new('ShunixBot RobotRules Spider 1.0');
     
       use LWP::Simple qw(get);
     
       {
        my $url = "http://google.com/robots.txt";
        my $robots_txt = get $url;
        $rules->parse($url, $robots_txt) if defined $robots_txt;
      }
     
      {
        my $url = "http://google.com/robots.txt";
        my $robots_txt = get $url;
        $rules->parse($url, $robots_txt) if defined $robots_txt;
      }
     
      # Now we can check if a URL is valid for those servers
      # whose "robots.txt" files we've gotten and parsed:
      # $c = get $url;
      if($rules->allowed($url)) {
     
        print "Yo sa marche cette crote";
     
     
       } else { $statut = "continue"; }
     
     
     
       }
     
     
    ###################################################################
    # Suppréssion des liens interdit (robots)
    ###################################################################
     
     
     
           sub interdit
           {
     
           { 
           my %temp; 
           @temp{@links} = (1) x @links; 
           @temp{@robots} = (0) x @robots; 
           @links = grep { $temp{$_} } @links; 
           } 
           $, = ", "; 
           # print @e;
     
           return @links;       
     
           }
     
     
     
    ###################################################################
    # Déplacement des tableaux de donné
    ###################################################################
     
         sub moving
         {
     
     
         @links = qw/ a.doc b.DOC c.rtf d.RTF e.pdf f.PDF g.xls h.XLS i.tif j.TIF k.tiff l.TIFF m.jpg n.JPG o.jpeg p.JPEG q.png r.PNG s.gif t.GIF/;
     
         my @a;
         {
          my @new_links;
           for( @links ) {
             if( /\.doc|\.rtf|\.pdf|\.xls|\.tif|\.tiff|\.jpg|\.jpeg|\.png|\.gif$/i ) {
               push @a, $_;
              }
               else {
                 push @new_links, $_;
                }
              }
             @links = @new_links;
            }
     
     
            return @links;
            return @a;
     
     
           }

  9. #9
    Membre actif Avatar de mobscene
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    331
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 331
    Points : 234
    Points
    234
    Par défaut
    Je trouve pas le moyen de comparer deux dates j'ai trouver time::local mais j'arrive pas a le faire marcher

    Quelqu'un sait il comment marche ce module ?

  10. #10
    Membre du Club Avatar de Batou
    Inscrit en
    Mars 2004
    Messages
    71
    Détails du profil
    Informations forums :
    Inscription : Mars 2004
    Messages : 71
    Points : 62
    Points
    62
    Par défaut local time
    yo, voila ce que j'ai trouve sur le forum y a un moment deja
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      my ($sec,$min,$hour,$month_day,$month,$year,$week_day,$year_day,$isdst) = localtime(time);
    j'espere que ca peut t'aider !
    ciao 8)

  11. #11
    Membre actif Avatar de mobscene
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    331
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 331
    Points : 234
    Points
    234
    Par défaut
    Thanks Batou

  12. #12
    Membre expert
    Avatar de 2Eurocents
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    2 177
    Détails du profil
    Informations personnelles :
    Âge : 54
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 2 177
    Points : 3 166
    Points
    3 166
    Par défaut
    En l'occurence, pour comparer deux dates, il vaut mieux utiliser la durée depuis EPOCH. C'est plus facile que de comparer tous les éléments du tableau issu de localtime (avec les rebouclages de secondes, minutes, heures, jours, etc, c'est la galère).

    C'est pourquoi on recommande l'usage de Time::Local.

    Un exemple, sur un calcul de délai entre deux dates, ici


    Ceci dit, pour des calculs de délais sur les dates, il existe aussi des modules plus abstraits et plus efficaces, comme Date::Calc et d'autres Date::*

    Bonne continuation.

  13. #13
    Membre actif Avatar de mobscene
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    331
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 331
    Points : 234
    Points
    234
    Par défaut
    Je fait des essaies avec ce ti robot codé en 1mn il marche mais seulement si @page ne contient qu'une url ce qui est quand même un comble pour un robot

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    #!/usr/local/bin/perl
     
    use LWP::UserAgent;
    use HTTP::Request;
    use HTTP::Response;
     
    @page = ("http://www.google.com","http://www.free.fr");
     
    my $ua = LWP::UserAgent->new();
    $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
    my $req = HTTP::Request->new(GET => @page);
    $req->referer("http://www.mansonfr.com");
     
    my $response = $ua->request($req);
     
    if ($response->is_error()) {
    printf " %s\n", $response->status_line;
    }
    else {
    my @content = $response->content();
    print "@content\n";
    }

  14. #14
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    73
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 73
    Points : 49
    Points
    49
    Par défaut
    Le plus dure a faire c'est le robot je sais pas comment l'organiser si un des pros du foum a une soluce mobscene j'ai la même erreur que toi

  15. #15
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    73
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 73
    Points : 49
    Points
    49
    Par défaut You pi :) :) :) :) :)
    Au lieu de me prendre la tête a faire un robot j'ai repris celui de mobscene



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    #!/usr/bin/perl -w
    use strict;
    use warnings;
     
    my $VERSION = "Robot experimental/0.1";
     
    use LWP::UserAgent;
    use HTML::LinkExtor;
    use URI::URL;
     
    $| = 1;
     
    sub spider (%);
     
    spider URL => '$url';
     
    sub spider (%) {
    	my %args = @_;
     
    	my @startlinks = ("http://dirthangel.free.fr");
     
    	push(@startlinks, $args{URL});
     
     
    	my $ua = LWP::UserAgent->new;
     
     
             $ua->agent('Mozilla/5.0 (compatible; Bot/0.1; +http://developpez.com');
     
    	WORKLOOP: while (my $link = shift @startlinks) {
     
    		for (my $i = 0; $i< $#startlinks; $i++) {
    			next WORKLOOP if $link eq $startlinks[$i];
    		}
    		print ">>>>> working on $link\n";
    	        HTML::LinkExtor->new(
              	  sub {
    			my ($t, %a) = @_;
    			my @links = map { url($_, $link)->abs() }
    			grep { defined } @a{qw/href img/};
     
    			# mark already spidered links for removal
    			foreach my $start_link (@startlinks) {
    				my $i = 0;
    				for (0 .. $#links) {
    					if ($links[$i++] eq $start_link) {
    						$links[$i -1] = "'REMOVE'";
    					}
    				}
    			}
     
    			@links = sort @links;
    			for (my $i = 0; $i< $#links; $i++) {
    				$links[$i] = "'REMOVE'" if $links[$i] eq $links[$i +1];
    			}
    			@links = grep { $_ ne "'REMOVE'" } @links;
     
                  @links = Array_Unique("@links");
     
    			print "+ $_\n" foreach @links;
     
    			push @startlinks, @links if @links;
              	  } ) -> parse(
               	  do {
                   		my $r = $ua->simple_request
                     	(HTTP::Request->new("GET", $link));
                   		$r->content_type eq "text/html" ? $r->content : "";
               	  }
             	)
    	}
    }
     
     
     
             sub Array_Unique
             {
             my %vu;
             ++$vu{$_} for @_;
             (keys %vu);
             }
    J'ai ajuté au robot un sous programme de suppréssion des doublons mais il provoque un bug . Pour vous aider a comprendre voila ce que trouve le robot sans le controle des doublons


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    >>>>> working on http://dirthangel.free.fr
    + http://dirthangel.free.fr/favicon.ico
    + http://dirthangel.free.fr/fichiers/css/page.css
    + http://dirthangel.free.fr/index.php
    >>>>> working on $url
    >>>>> working on http://dirthangel.free.fr/favicon.ico
    >>>>> working on http://dirthangel.free.fr/fichiers/css/page.css
    >>>>> working on http://dirthangel.free.fr/index.php
    + http://dirthangel.free.fr/favicon.ico
    + http://dirthangel.free.fr/fichiers/css/page.css
    + http://dirthangel.free.fr/news.htm
    + http://dirthangel.free.fr/index.php
    + http://dirthangel.free.fr/biographie.htm
    + http://dirthangel.free.fr/concert.htm
    + http://dirthangel.free.fr/interview.htm
    + http://dirthangel.free.fr/multimedia.htm
    + http://dirthangel.free.fr/downloads.htm
    + http://dirthangel.free.fr/gallerie.htm
    + http://dirthangel.free.fr/fanzine.htm
    + http://dirthangel.free.fr/forum.php
    + http://dirthangel.free.fr/liens.htm
    + http://dirthangel.free.fr/webmaster.htm
    + http://dirthangel.free.fr/contact.htm
    + http://dirthangel.free.fr/wallpaper.htm
    >>>>> working on http://dirthangel.free.fr/favicon.ico
    >>>>> working on http://dirthangel.free.fr/fichiers/css/page.css
    >>>>> working on http://dirthangel.free.fr/news.htm
    + http://dirthangel.free.fr/favicon.ico
    + http://dirthangel.free.fr/fichiers/css/page.css
    + http://dirthangel.free.fr/news.htm
    >>>>> working on http://dirthangel.free.fr/index.php
    + http://dirthangel.free.fr/index.php
    >>>>> working on http://dirthangel.free.fr/biographie.htm
    + http://dirthangel.free.fr/biographie.htm
    + http://www.marilynmanson.com/
    >>>>> working on http://dirthangel.free.fr/concert.htm
    + http://dirthangel.free.fr/concert.htm
    >>>>> working on http://dirthangel.free.fr/interview.htm
    + http://dirthangel.free.fr/interview.htm
    >>>>> working on http://dirthangel.free.fr/multimedia.htm
    + http://dirthangel.free.fr/multimedia.htm
    + http://dirthangel.free.fr/clips.htm
    + http://dirthangel.free.fr/live.htm
    + http://dirthangel.free.fr/audio.htm
    >>>>> working on http://dirthangel.free.fr/downloads.htm
    + http://dirthangel.free.fr/downloads.htm
    + http://dirthangel.free.fr/winamp.htm
    + http://dirthangel.free.fr/bootleg.htm
    >>>>> working on http://dirthangel.free.fr/gallerie.htm
    + http://dirthangel.free.fr/gallerie.htm
    >>>>> working on http://dirthangel.free.fr/fanzine.htm
    + http://dirthangel.free.fr/fanzine.htm
    >>>>> working on http://dirthangel.free.fr/forum.php
    >>>>> working on http://dirthangel.free.fr/liens.htm

    Et avec


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    >>>>> working on http://dirthangel.free.fr
    + http://dirthangel.free.fr/favicon.ico
    + http://dirthangel.free.fr/fichiers/css/page.css
    + 
    + http://dirthangel.free.fr/index.php
    + 
    >>>>> working on $url
    >>>>> working on http://dirthangel.free.fr/favicon.ico
    >>>>> working on http://dirthangel.free.fr/fichiers/css/page.css
    J'ai bien chercher et , je ne trouve pas de soluce ?

  16. #16
    Membre expert
    Avatar de 2Eurocents
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    2 177
    Détails du profil
    Informations personnelles :
    Âge : 54
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 2 177
    Points : 3 166
    Points
    3 166
    Par défaut
    Cette ligne m'interpelle ...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    @links = Array_Unique("@links");
    Est-ce voulu, de quoter @links ?

    A l'évidence, cela ne va pas faciliter le traitement de toute la liste comme telle, non ?

    A toi de voir ...

  17. #17
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    73
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 73
    Points : 49
    Points
    49
    Par défaut
    Ouais les quotes sont une erreur j'ai corrigé sa depuis mon post et sa marche pas j'ai encore des doublons

    par contre sa sert a quoi

    $| = 1;
    dans le script ? Je pensais que c'etait pour régler la profondeur d'indexation mais en fait non

  18. #18
    Membre actif Avatar de mobscene
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    331
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 331
    Points : 234
    Points
    234
    Par défaut
    Ta fonction de sert a rien vaut mieux dans ta config sql mettre la table dans laquel sont stocké les adresse en UNIQUE et la sa ta simplifie tout , par contre j'essaie de mettre au point un sous programme pour trier les liens c'est a dire supprimé les liens vers des fichiers .zip, rar, tar et autre

  19. #19
    Membre actif Avatar de mobscene
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    331
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 331
    Points : 234
    Points
    234
    Par défaut
    moi je pensais que

    $| = 1;
    c'etait le temps pendant lequel le robot pouvait tourner mais en fait c'est pas sa !

    Quelqu'un sait il a quoi sert $| = 1; ????

  20. #20
    Membre actif Avatar de mobscene
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    331
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 331
    Points : 234
    Points
    234
    Par défaut
    Je vais ajouter le multithreading

Discussions similaires

  1. Moteur de recherche sans langage serveur
    Par laurentSc dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 12/02/2014, 07h48
  2. Moteur de recherche: quel langage choisir?
    Par Florent-g dans le forum Langages de programmation
    Réponses: 6
    Dernier message: 13/11/2009, 18h40
  3. comment faire ma base de donnée pour un moteur de recherche
    Par HoB dans le forum Décisions SGBD
    Réponses: 2
    Dernier message: 04/05/2004, 15h07
  4. Moteur de recherche par date
    Par Prue dans le forum ASP
    Réponses: 17
    Dernier message: 27/08/2003, 16h07
  5. [Technique] Index, comment font les moteurs de recherche ?
    Par bat dans le forum Décisions SGBD
    Réponses: 4
    Dernier message: 25/10/2002, 15h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo