Subject: | Unicode problems, sometimes |
I have problems when using WWW::Search::Google with search terms
containing umlauts and other non-ascii characters. Unfortunately I don't
see a real pattern in the problems. With the attached file and perl5.8.0
I don't get any results (you need to put your Google API key in ~/.
googleapikey or set the $my_api_key variable). If the only commented
line in the script is enabled, then there are results. From my point of
view user code should never need to use Encode calls; this would be the
responsibility of the underlying module, either WWW::Search::Google or
Net::Google.
Unfortunately with a recent perl (5.8.7 or 5.8.8) I never get a result,
regardless of using the encode() call or not.
Regards,
Slaven
Subject: | google.pl |
#!/usr/bin/perl -w
use WWW::Search::Google;
use Data::Dumper;
use Encode;
my $my_api_key;
my $google_api_key_file = "$ENV{HOME}/.googleapikey";
if (open(APIKEY, $google_api_key_file)) {
$my_api_key = <APIKEY>;
$my_api_key =~ s{[\r\n\s+]}{}g;
close APIKEY;
warn "Loaded Google API key from $google_api_key_file...\n";
}
my $search = WWW::Search->new("Google", key => $my_api_key);
$query = "allintitle:\"Sigmund Bergmann Stra\337e in Spandau\" site:luise-berlin.de OR site:berlin-chronik.de OR site:berlingeschichte.de OR site:berliner-lesezeichen.de";
#$query = Encode::encode("utf-8", $query);
$search->native_query($query);
while(my $result = $search->next_result) {
warn Dumper($result);
}
__END__