Google API Results

Discussion in 'Google API' started by mattih5, Jan 5, 2007.

  1. #1
    Hi,

    I'm having a bit of discrepency with the results that Google returns in it's API.

    Say for example I do a search using the api for matches intitle with the phrase "internet marketing system" e.g:

    
    function google_results_intitle() {
    		//Function: Returns array of total google matches within website title
    		set_time_limit(1000);
    		$receivedError=0; 
    		$maxErrorsAllowed=5; 
    		$gs = new GoogleSearch(); 
    		$gs->setKey($this->goog_key); 		
    		$gs->setMaxResults(1); 
    		//$gs->setSafeSearch(true);
    		foreach($this->preped_keywords as $key=>$val){			
    			/*
    			* We're using a do/while loop to counter the problem
    			* of http header errors
    			*/
    			$gs->setQueryString("intitle:\"$val\""); 
    			do{ 
    				$search_result = $gs->doSearch(); ##do the search
    			if($gs->getError()){ 
    				$receivedError++; ##increment error count
            sleep(5); ##sleep script for 5 seconds
    			}else{ 
    				$receivedError=0;  ##reset error count
          } //end if
    		} while ( $receivedError && ($receivedError <= $maxErrorsAllowed)); 
    			$search[$val] = $search_result->result[estimatedTotalResultsCount];
    		} //end foreach
    		return $search; 
    		/*if(!$search_result){ 
    			if($err = $gs->getError()){ 
    				return "Couldn't retrieve result";
    				//echo "<br>Error: " . $err; 
    				//exit("<br>Exiting..."); 
    			} //end if
    		} else {
    			return $search_result->result[estimatedTotalResultsCount];
    		} //end if*/
    	} //end function
    
    PHP:
    I get 122 matches BUT if I repeat this in the Google search bar: "intitle:internet marketing system" I get 1,200,000 results - this is a massive difference in results. Am I doing something wrong?

    Thanks in advance
     
    mattih5, Jan 5, 2007 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Googles results vary wildly depending on the datacenter they decide to use. Nothing you can do about it.

    In your case I expect there is some kind of bug as the results seem way off. Do other searches come up OK?
     
    mad4, Jan 5, 2007 IP
  3. mattih5

    mattih5 Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi, thanks for your reply.

    Yes all the results appear fine. Although, when I do a generic search for the keyword the results appear in the millions.

    Can you see anything wrong with the code? SafeSearch and filtering are both off.
     
    mattih5, Jan 5, 2007 IP