in reply to Perl and Google API

Thanks for your replies so far.

To mrbbking:

> Do they have any kind of throttle?

The Google API FAQ doesn't mention one, only the 1,000 max queries. I've tried sleeping for 5-10 secs, with no luck.

> Is there something strange about the second word in your list? What happens if you delete the first word from your list and start the process with the second word? Does the first connection still succeed and the second still fail?

It looks like this may be the problem. I took out the first word and immediately got the 500 Error. I've tried messing around with the input encoding parameter, as the second word has got an 'á' in it, but nothing works, even UTF-8.

> The 500 is from Google, right?

Yes.

To Mr. Muskrat:

> Well, you haven't shown us your code that pertains to CGI. So we can't possibly tell you why you're getting a 500 error.

I don't have any CGI code. Here's the code in full (with the Google API key ($key) changed to 0's).
#!/usr/bin/perl use SOAP::Lite; use strict; my $key='00000000000000000000000000'; my $fh = "wordList.txt"; open FH, "$fh" or die "Can't open: $!"; open OUTFILE, ">goodWords.txt"; foreach (<FH>) { chomp; print $_; my $googleSearch = SOAP::Lite -> service("file:GoogleSearch.wsdl") +; my $result = $googleSearch -> doGoogleSearch($key, $_, 0, 10, "fal +se", "", "false", "lang_es", "latin1", "latin1"); my $hitCount = qq{$result->{'estimatedTotalResultsCount'}}; print " returns about $hitCount hits.\n"; if ($hitCount > 200) { print OUTFILE "$_ returns about $hitCount hits.\n"; } } close OUTFILE; close FH;
That's all.

BTW, what's weird about $hitCount, and why is $matchCount better? I'm a total newbie so don't know about these things. :)

As ever, thanks to all the Monks (especially those who've helped me out here).

doonyakka


Update: this particular problem solved, with the very kind help of dree. The problem was not with the code, but with Soap::Lite v0.52. dree had Soap::Lite v0.46 and had no problems running the program, and when he upgraded to v0.52 it stopped working (ie., he got the dreaded 500 error). So, I installed 0.46 and hey presto! it's working fine now. Thanks dree!

Replies are listed 'Best First'.
Re: Re: Perl and Google API
by keymon (Beadle) on May 18, 2002 at 13:31 UTC
    BTW, what's weird about $hitCount, and why is $matchCount better? I'm a total newbie so don't know about these things. :)
    The "$" looks like an "S". Do the switch, and see if it makes a difference in perception.... ;-)
      hehe...of course...that was part of the attraction, my first perl pun ;)