Google API help

  • clifffrog
  • Novice
  • Novice
  • clifffrog
  • Posts: 24

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

If I'm not mistaken, doesn't Google recommend 250 keywords or less, else you might encounter errors?
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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.
  • clifffrog
  • Novice
  • Novice
  • clifffrog
  • Posts: 24

Post 3+ Months Ago

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
  • clifffrog
  • Posts: 24

Post 3+ Months Ago

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 158 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.