Commits

Shlomi Fish committed a02dc80

Version 0.0101 that fixes the handling of no-results searches.

  • Participants
  • Parent commits aefab92
  • Tags releases/WWW-Search-AOL/0.01/0.0101

Comments (0)

Files changed (4)

modules/WWW-Search-AOL/Changes

 Revision history for WWW-Search-AOL
 
+0.0101 Tue May  2 12:53:47 IDT 2006
+    Fixed handling searches with no results.
+
 0.0100 Fri Apr 21 14:03:07 IDT 2006
     First version, released on an unsuspecting world. Works from what
     I tested. Skeleton for this module was derived from WWW-Search-MSN,

modules/WWW-Search-AOL/MANIFEST

 Build.PL
 Changes
 lib/WWW/Search/AOL.pm
+Makefile.PL
 MANIFEST
 META.yml # Will be created by "make dist"
 README
 t/00-load.t
 t/01basic.t
+t/02no-results.t
 t/pod-coverage.t
 t/pod.t
-Makefile.PL

modules/WWW-Search-AOL/lib/WWW/Search/AOL.pm

 
 =cut
 
-our $VERSION = '0.0100';
+our $VERSION = '0.0101';
 
 use vars qw(@ISA);
 
 {
     my ($self, $tree) = @_;
 
+    if ($self->{'_AOL_no_results_found'})
+    {
+        return 0;
+    }
+
     if ($self->{'_AOL_first_retrieve_call'})
     {
         $self->{'_AOL_first_retrieve_call'} = undef;
-        
+
+        my $nohit_div = $tree->look_down("_tag", "div", "id", "nohit");
+
+        if (defined($nohit_div))
+        {
+            if (($nohit_div->as_text() =~ /Your search for/) &&
+                ($nohit_div->as_text() =~ /returned no results\./)
+               )
+            {
+                $self->approximate_result_count(0);
+                $self->{'_AOL_no_results_found'} = 1;
+                return 0;
+            }
+        }
+
         my $wr_div = $tree->look_down("_tag", "div", "id", "wr");
 
         if ($wr_div->as_text() =~ m{page 1 of (\d+)})

modules/WWW-Search-AOL/t/02no-results.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 7;
+
+# TEST
+BEGIN { use_ok('WWW::Search'); };
+# TEST
+BEGIN { use_ok('WWW::Search::Test'); };
+# TEST
+BEGIN { use_ok('WWW::Search::AOL'); };
+
+$WWW::Search::Test::oSearch = new WWW::Search('AOL');
+# TEST
+isa_ok ($WWW::Search::Test::oSearch, "WWW::Search");
+$WWW::Search::Test::oSearch->env_proxy('yes');
+
+my $debug = 0;
+my $dump  = 0;
+
+$debug = 0;
+$dump = 0;
+
+my $count = 
+    WWW::Search::Test::count_results(
+        'normal',
+        'link:http://wnviuncsivndkvndvjnbpwnvinsvdiondvs.goj/',
+        0,
+        49,
+        $debug,
+        $dump
+    );
+
+# TEST
+is ($WWW::Search::Test::oSearch->approximate_result_count(), 0,
+    "approximate_result_count is 0 for no results found search.");
+
+# TEST
+is ($count, 0, "Checking for count of no results found search");
+
+my @results = $WWW::Search::Test::oSearch->results();
+
+# TEST
+is_deeply (\@results, [], "Checking for results of no results found search");
+