Google API help

  • clifffrog
  • Novice
  • Novice
  • No Avatar
  • Joined: Jan 12, 2004
  • Posts: 24
  • Status: Offline

Post January 13th, 2004, 6:43 pm

Hi,
I'm using the Google API to query google and see how well I'm ranking for my keywords. It works pretty well, but I have a long list of keyords to check (>1000) and every once in a while I get a timeout error, and my program exits, and I need to manually restart it.



Code: [ Select ]
my $result = $googleSearch -> doGoogleSearch($key, $query, 0, 10, "false", ""
, "false", "", "latin1", "latin1");
  1. my $result = $googleSearch -> doGoogleSearch($key, $query, 0, 10, "false", ""
  2. , "false", "", "latin1", "latin1");


What I want to do is know when a timeout error occurs, and sleep for 5 seconds, then try again. I don't know how to find out when an error occurs.

Quote:
SOAP call failed: 500 read timeout at serps.pl line 127

is the error I see, and line 127 is the line of code listed above. When I try a check on the variable $result after this line, it's too late, the program has exited.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 13th, 2004, 6:43 pm

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post January 13th, 2004, 7:09 pm

If I'm not mistaken, doesn't Google recommend 250 keywords or less, else you might encounter errors?
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post January 13th, 2004, 7:18 pm

More:

http://www.searchengines.com/searchEnginesRankings.html
http://www.marketleap.com/help/seo101/titlestags.htm


I'll just start with those. If you want further info try a Google search for "250 keywords" --1,890,000 results.

I realize that your question is re: programming, but I think your excessive number of keywords might be bogging you down.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • clifffrog
  • Novice
  • Novice
  • No Avatar
  • Joined: Jan 12, 2004
  • Posts: 24
  • Status: Offline

Post January 14th, 2004, 3:58 pm

Hey ATNO/TW

I'm doing queries for one keyword at a time, and then record how my site is ranking for each keyword. My comment about having 1000 keywords just means that I'll be sending my daily maximum number of queries to the google API.

What I'm looking for is purely programming, as you noted.

I'm hoping that there is some $result->isError() or eval(); way of doing it, but I haven't figured it out, and I don't know SOAP.
  • clifffrog
  • Novice
  • Novice
  • No Avatar
  • Joined: Jan 12, 2004
  • Posts: 24
  • Status: Offline

Post January 14th, 2004, 4:34 pm

I got it to do what I want, and it all works perfectly :D


Code: [ Select ]
    
my $result;
eval{
        $result = $googleSearch -> doGoogleSearch($key, $query, $start, 10, "false", "", "false", "", "latin1", "latin1");
};
if($@){
    print "Error reason: $@\n";
    sleep 3;
    $result = $googleSearch -> doGoogleSearch($key, $query, $start, 10, "false", "", "false", "", "latin1", "latin1");
}
  1.     
  2. my $result;
  3. eval{
  4.         $result = $googleSearch -> doGoogleSearch($key, $query, $start, 10, "false", "", "false", "", "latin1", "latin1");
  5. };
  6. if($@){
  7.     print "Error reason: $@\n";
  8.     sleep 3;
  9.     $result = $googleSearch -> doGoogleSearch($key, $query, $start, 10, "false", "", "false", "", "latin1", "latin1");
  10. }


now I can turn it into a while loop, and try 3 times before giving up etc.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 124 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.