for(@ {$self->{results}}) { # iterate over all avaible results
if($_->url =~ /$string/) { # does the url match the given pattern?
push@return, $_; # push the result object to @return
}
}
if(scalar(@return) == 0) { return; } # return boolean false if no matches were found
return@return; # return the array of result objects
}
1;
__END__
=head1 NAME
WWW::Scroogle - Perl Extension for Scroogle
=head1 CAVEAT
Please note that using Scroogle.org - which this module is using (may) be a violation of Google's "Terms of Service", of which scroogle.org has been reminded. You can find the TOS at http://www.google.com/terms_of_service.html
Scroogle.org does violate the "No Automated Query" section.
The Author has searched for some easy way to get google results, he stumbled across the Google SOAP Api to which turned out to be useless because google will not give away keys to it anymore, later he found out about Googles Ajax api which turns out to be useless as you can only get the first 20results for a searchterm, now there was only one possibility left: parsing the html output of google webquerys; but while thinking about that the author realized scroogle.org, those guys have already done that job and do provide nice, clean html output which is much easier to parse than google.
To come to an end: WWW::Scroogle does one job - it provides you with usable scroogle.org search results.
=head1 SYNOPSIS
use WWW::Scroogle;
# create a new WWW::Scroogle object
my $scroogle = WWW::Scroogle->new;
# set searchstring
$scroogle->searchstring('foobar');
# get search_results
my $results = $scroogle->get_results;
# print rank of the first website whose url matches 'wikipedia'
print $results->position(qr{wikipedia}).'\n';
# get all results
my @results = $results->get_results;
# iterate over all results
for (@results){
print $_->url."\n";
}
=head1 DESCRIPTION
WWW::Scroogle uses LWP to fetch the search results from scroogle and parses
the returned html output.
=head1 METHODS
=head2 WWW::Scroogle->new
Returns a new WWW::Scroogle object.
=head2 $searchstring = $scroogle->searchstring
returns the current searchstring
=head2 $scroogle->set_searchstring($searchstring)
sets $searchstring as the current searchstring
=head2 $language = $scroogle->language
returns the current Language - defaults to all
=head2 $scroogle->set_language($language)
sets $language as the current language
=head2 @languages = $scroogle->languages
Returns a list of avaible languages.
=head2 $num_results = $scroogle->num_results
Returns the current number of search results - defaults to 100
=head2 $scroogle->set_num_results
sets the number of results
=head2 $scroogle->perform_search
performs search and stores result. expects that a searchstring was set.
=head2 $scroogle->nresults
returns number of results or false if no results are avaible
=head2 $scroogle->has_results
returns true if there are stored results and false if there are no results avaible