Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Google::Search language

by welle (Beadle)
on May 15, 2011 at 08:01 UTC ( #904936=perlquestion: print w/ replies, xml ) Need Help??
welle has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I am playing with the module Google::Search to search the top results of a simple query. The module works fine. Though, I couldn't figure out how to restrict the search to a specific language. So far as I know the API supports this (lr=_lang_xx). Any Idea?

use Google::Search; my $search = Google::Search->Web([ lr => 'it' ], query => "site:su +nrise.ch" ); while ( my $result = $search->next ) { print $result->rank, " ", $result->uri, "\n"; }

This code snippet produces results in all languages used by this multilanguage site.

Thank you for your ideas. Welle

Comment on Google::Search language
Download Code
Re: Google::Search language
by Perlbotics (Canon) on May 15, 2011 at 10:22 UTC

    It's neither lr=_lang_xx nor lr=xx but lr=lang_xx (see here).

    However, the [ lr => 'lang_it' ] notation seems to be ignored by the Google::Search API. Try this:

    my $search = Google::Search->Web( query => { q => "site:sunrise.ch +", lr => 'lang_it', hl => 'it', }, # key => $your_google_api_key, # referrer => $valid_referrer, );
    ...which works better.
    You might also want to check $search->error and $search->error->reason ...

    Hint: Suspected Terms of Service Abuse. Please see http://code.google.com/apis/errors and key/referrer-comments above...

      Thank you very much, it works perfectly.

Reaped: Re: Google::Search language
by NodeReaper (Curate) on May 15, 2011 at 10:54 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://904936]
Approved by Perlbotics
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2015-07-07 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (89 votes), past polls