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 :

Cherche parseur fichier robots.txt


Sujet :

Langage Perl

  1. #1
    Membre du Club Avatar de bluecurve
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 68
    Points : 43
    Points
    43
    Par défaut Cherche parseur fichier robots.txt
    Bonjour je suis nouveaux sur le forum comme en Perl , je cherche un parser de fichier robots.txt autre que www::robotrules car il ne convient pas a mes besoins il ne sort qu'une liste manger genre
    /administration/
    pas vraiment pratique.

    connaissez vous un script qui puisse le retourner des url du genre

    http://www.clubic.com/s/infoprix.php
    http://www.clubic.com/s/infoprix_2.php
    http://www.clubic.com/shopper/infoprix_2.php
    ????

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    210
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2004
    Messages : 210
    Points : 99
    Points
    99
    Par défaut
    Moi j'ai sa a te proposer mais il y a un problème avec la fonction replace elle ne retournr que le résultats pour le premier item du tableau


    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
    #!C:\Perl\bin\perl.exe 
     
     
    ################################## 
    # Tableau d'adresse(s) 
    ################################## 
     
    @EE = ("http://www.google.com/robots.txt","http://search.msn.fr/robots.txt"); 
     
     
    for $X( @EE ) { 
     
     
    ################################## 
    # Appelle des fonctions 
    ################################## 
     
    @EE = find(@EE); 
    @EE = replace(@EE); 
    print "@EE"; # Récupération de robotx.txt 
     
    ################################## 
    # Recherche des robots.txt 
    ################################## 
     
    sub find { 
      use LWP::Simple; 
        my @resultat; 
        for my $url( @_ ) { 
            push @resultat, get($url); 
        } 
        return @resultat; 
     } 
     
    ################################## 
    # Parser robots.txt 
    ################################## 
     
    sub replace 
    { 
     my @resultat; 
    for my $T( @_ ) { 
     push @resultat,  $T =~ s/User-agent: \*//ig && 
                      $T =~ s/Allow.*//g && 
                      $X =~ s/\/robots\.txt//ig && 
                      $T =~ s/Disallow: /$X\/$1/ig && 
                      $T =~ s/\/\//\//ig && 
                      $T =~ s/http:\//http:\/\//ig && 
                      $T =~ s/^\n*//ig && 
                      $T =~ s/\n$//ig && $T; 
      } 
      return @resultat; 
     }
    }

  3. #3
    Membre du Club Avatar de bluecurve
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 68
    Points : 43
    Points
    43
    Par défaut
    Sa pose problème effectivement , en plus pas mal l'dée du push mais je comprend pas pourquoi sa retourne que le premier element du tableau

  4. #4
    Membre du Club Avatar de bluecurve
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 68
    Points : 43
    Points
    43
    Par défaut
    Wouha le début fait ce que je veut mais replace() c'est une vraie torture mentale.



  5. #5
    Membre du Club Avatar de bluecurve
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 68
    Points : 43
    Points
    43
    Par défaut
    j'ai testé sa pour voir si replace() renvoyait les 2 item et ben oui donc c'est les RegXp qui sont pas bon


    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
    #!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); 
    print @site; # Récupération de robotx.txt 
     
    ################################## 
    # 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
    {
    my @result;
    for $T( @_ ) {
    push @result, print "$T";
     
     }
    }
    Au secour y a t'il un expert en RegXp dans le coin ???

  6. #6
    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 et les regXp c'est comme avec l'anglais sa vas pas mais je te conseillerais de voir du coté de

    http://search.cpan.org/~dland/Regexp...15/Assemble.pm

    Je vais d'ailleur faire un poste au sujet de ce module pk je suis faché ave l'Anglais
    Everybody have in their the potential to be their own god : Marilyn Manson

  7. #7
    Membre actif
    Inscrit en
    Février 2005
    Messages
    167
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 167
    Points : 203
    Points
    203
    Par défaut
    Citation Envoyé par bluecurve
    Wouha le début fait ce que je veut mais replace() c'est une vraie torture mentale.
    heuh... le lire aussi. Peux-tu simplement mettre deux liste : une ce que tu reçois comme robots.txt et deux, ce que tu veux à l'arrivée. Je suis sûr de pouvoir faire une "one-liner" mais ça me prend la tête à essayer de comprendre le but recherché.

    N

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

    Informations forums :
    Inscription : Avril 2005
    Messages : 6
    Points : 5
    Points
    5
    Par défaut
    ben le but recherché est d'avoir une liste d'url complete et pas juste des morceaux comme sort www::RobotRules il sort


    /searchhistory/ c'est trop pratique j'adore
    Voici qq chose de plus pratique

    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
    http://www.google.fr/search
    http://www.google.fr/groups
    http://www.google.fr/images
    http://www.google.fr/catalogs
    http://www.google.fr/catalog_list
    http://www.google.fr/news
    http://www.google.fr/nwshp
    http://www.google.fr/?
    http://www.google.fr/addurl/image?
    http://www.google.fr/pagead/
    http://www.google.fr/relpage/
    http://www.google.fr/sorry/
    http://www.google.fr/imgres
    http://www.google.fr/keyword/
    http://www.google.fr/u/
    http://www.google.fr/univ/
    http://www.google.fr/cobrand
    http://www.google.fr/custom
    http://www.google.fr/advanced_group_search
    http://www.google.fr/advanced_search
    http://www.google.fr/googlesite
    http://www.google.fr/preferences
    http://www.google.fr/setprefs
    http://www.google.fr/swr
    http://www.google.fr/url
    http://www.google.fr/wml?
    http://www.google.fr/xhtml?
    http://www.google.fr/imode?
    http://www.google.fr/jsky?
    http://www.google.fr/pda?
    http://www.google.fr/sprint_xhtml
    http://www.google.fr/sprint_wml
    http://www.google.fr/pqa
    http://www.google.fr/palm
    http://www.google.fr/hws
    http://www.google.fr/bsd?
    http://www.google.fr/linux?
    http://www.google.fr/mac?
    http://www.google.fr/microsoft?
    http://www.google.fr/unclesam?
    http://www.google.fr/answers/search?q=
    http://www.google.fr/local?
    http://www.google.fr/local_url
    http://www.google.fr/froogle?
    http://www.google.fr/froogle_
    http://www.google.fr/print?
    http://www.google.fr/scholar?
    http://www.google.fr/complete
    http://www.google.fr/sponsoredlinks
    http://www.google.fr/videosearch?
    http://www.google.fr/videopreview?
    http://www.google.fr/videoprograminfo?
    http://www.google.fr/maps?
    http://www.google.fr/translate?
    http://www.google.fr/ie?
    http://www.google.fr/sms/demo?
    par contre c'est vraie que c'est bizarre que les regXP ne renvoie que le premier Item

  9. #9
    Membre du Club Avatar de bluecurve
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 68
    Points : 43
    Points
    43
    Par défaut
    voila je pense être proche du but mais j'ai juste un ti problème de variable

    Donc voila ce que j'obtient en mettand $1 comme variable dans le regXp

    Code :

    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
    #!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
     }
    }
    /search
    /groups
    /images
    /catalogs
    /catalog_list
    /news
    /nwshp
    /?
    /addurl/image?
    /pagead/
    /relpage/
    /sorry/
    /imgres
    /keyword/
    /u/
    /univ/
    /cobrand
    /custom
    /advanced_group_search
    /advanced_search
    /googlesite
    /preferences
    /setprefs
    /swr
    /url
    /wml?
    /xhtml?
    /imode?
    /jsky?
    /pda?
    /sprint_xhtml
    /sprint_wml
    /pqa
    /palm
    /hws
    /bsd?
    /linux?
    /mac?
    /microsoft?
    /unclesam?
    /answers/search?q=
    /local?
    /local_url
    /froogle?
    /froogle_
    /print?
    /scholar?
    /complete
    /sponsoredlinks
    /videosearch?
    /videopreview?
    /videoprograminfo?
    /maps?
    /translate?
    /ie?
    /sms/demo?/s/infoprix.php
    /s/infoprix_2.php
    /shopper/infoprix_2.php
    -----------------

    le même code mais avec $0

    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
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/search
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/groups
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/images
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/catalogs
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/catalog_list
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/news
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/nwshp
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/addurl/image?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/pagead/
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/relpage/
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/sorry/
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/imgres
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/keyword/
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/u/
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/univ/
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/cobrand
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/custom
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/advanced_group_search
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/advanced_search
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/googlesite
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/preferences
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/setprefs
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/swr
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/url
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/wml?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/xhtml?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/imode?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/jsky?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/pda?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/sprint_xhtml
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/sprint_wml
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/pqa
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/palm
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/hws
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/bsd?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/linux?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/mac?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/microsoft?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/unclesam?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/answers/search?q=
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/local?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/local_url
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/froogle?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/froogle_
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/print?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/scholar?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/complete
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/sponsoredlinks
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/videosearch?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/videopreview?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/videoprograminfo?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/maps?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/translate?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/ie?
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/sms/demo?/C:\Documents and Settings\Teddy\Bureau\rules.pl/s/infoprix.php
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/s/infoprix_2.php
    /C:\Documents and Settings\Teddy\Bureau\rules.pl/shopper/infoprix_2.php
    Ou est le prb avec $0 ???

  10. #10
    Membre actif
    Inscrit en
    Février 2005
    Messages
    167
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 167
    Points : 203
    Points
    203
    Par défaut
    Citation Envoyé par bluecurve
    Ou est le prb avec $0 ???
    $0 contient le nom du programme. Rien à voir avec les captures des regexps.

    N

Discussions similaires

  1. fichier robots.txt et spider ?
    Par nfluch dans le forum Général Conception Web
    Réponses: 2
    Dernier message: 02/08/2013, 14h03
  2. [debutant(e)] Accès au fichier robot.txt
    Par SPACHFR dans le forum Référencement
    Réponses: 2
    Dernier message: 12/06/2013, 14h13
  3. Fichier robots.txt pour google
    Par ni-ni13 dans le forum Référencement
    Réponses: 0
    Dernier message: 27/09/2010, 14h45
  4. Cacher le fichier robots.txt aux navigateurs
    Par itmak dans le forum Apache
    Réponses: 3
    Dernier message: 04/01/2010, 12h34
  5. Comment créer le fichier robots.txt
    Par tremeur53 dans le forum Référencement
    Réponses: 2
    Dernier message: 13/05/2009, 02h30

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