diff --git a/harvestCorpus.pl b/harvestCorpus.pl index c6a37d2..8aef65d 100755 --- a/harvestCorpus.pl +++ b/harvestCorpus.pl @@ -24,8 +24,8 @@ " " x (5 + length($programme)) . "[ -s fichier_corpus ] [ -iv ]\n" . " $programme -h\n\n"; -my $version = "2.0.7"; -my $dateModif = "19 Septembre 2017"; +my $version = "2.1.0"; +my $dateModif = "19 Octobre 2017"; # Variables my $aide = 0; @@ -204,7 +204,6 @@ next if $ligne =~ /"(scrollId|nextScrollURI)": /o; print LOG "$ligne\n"; } - # print LOG "$json\n"; print OUT "#\n# Requête : \"$uri\"\n#\n"; $perl = decode_json $json; my %top = %{$perl}; @@ -212,11 +211,19 @@ if ( $total > 0 ) { print OUT "# Nombre de réponses : $total\n#\n\n"; $format = sprintf("%%0%dd", length($total) + 1); - if ( $top{'nextScrollURI'} ) { - $suivant = $top{'nextScrollURI'}; + if ( $top{'scrollId'} ) { + my $scrollId = $top{'scrollId'}; + if ( $top{'nextScrollURI'} ) { + $suivant = "$url" . "1&$out&size=$size&scroll=167s&"; + $suivant .= "scrollId=$scrollId&sid=scodex-harvest-corpus";; + } + else { + $suivant = ""; + } } else { - $suivant = ""; + print STDERR "Pas de \"scrollId\"\n"; + exit 6; } my @hits = @{$top{'hits'}}; foreach my $hit (@hits) { @@ -236,17 +243,17 @@ # Itérations suivantes while ( $suivant ) { - $json = get("$suivant&sid=scodex-harvest-corpus"); + $json = get("$suivant"); $perl = undef; if ( defined $json ) { - print LOG "$json\n"; + foreach my $ligne (split(/[\n\r]+/, $json)) { + next if $ligne =~ /"(scrollId|nextScrollURI)": /o; + print LOG "$ligne\n"; + } $perl = decode_json $json; my %top = %{$perl}; - if ( $top{'nextScrollURI'} ) { - $suivant = $top{'nextScrollURI'}; - } - else { - $suivant = ""; + if ( not $top{'nextScrollURI'} ) { + $suivant = ""; } my @hits = @{$top{'hits'}}; foreach my $hit (@hits) {