How to use Perl Google :: Search to search for specific URLs?

The Google :: Search module based on the AJAX search API doesn't seem to work very well, or is it just me?

For example, I use firefox to search google for: http://bloggingheads.tv/forum/member.php?u=12129

It brings results.

But when I use the module in this way:

$google_search = Google::Search->Web ( q => "http://bloggingheads.tv/forum/member.php?u=12129" ); @result = $google_search->all; 

I get nothing in the array.

Any idea?

It seems that this API does not bring the same results as when searching manually, am I missing something?

+4
source share
2 answers

I had a similar problem with cyrillic queries. Both Google::Search and REST::Google from CPAN did not work for me - they yielded fewer or fewer results compared to the manual test.

In the end, I wrote a cleanup module using WWW::Mechanize and HTML::TreeBuilder .

Here is a sample to get the statistics of the result:

 my $tree = HTML::TreeBuilder->new_from_content($content); if (my $div = $tree->look_down(_tag => 'div', id => 'resultStats')) { my $stats = $div->as_text(); } else { warn "no stats" } 
+1
source

Looking at the POD for Google :: Search , it looks like it expects you to pass Web searches, not URLs. I downloaded the test script from CPAN, ran it, and seemed to give the expected results:

 use strict; use warnings; use Google::Search; my $search = Google::Search->Web(q => "rock"); my $result = $search->first; while ($result) { print $result->number, " ", $result->uri, "\n"; $result = $result->next; } print $search->error->reason, "\n" if $search->error; __END__ 0 http://www.rock.com/ 1 http://en.wikipedia.org/wiki/Rock_music 2 http://en.wikipedia.org/wiki/Rock_(geology) 3 http://rockyourphone.com/ 4 http://rockhall.com/ 5 http://www.co.rock.mn.us/ 6 http://www.co.rock.wi.us/ 7 http://www.rockride.org/ etc... 

I understand that this does not specifically answer your question, but perhaps it guides you in the right direction.

0
source

All Articles