Parser for determining Google Position

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
visionmaster
Forum Contributor
Posts: 139
Joined: Wed Jul 14, 2004 4:06 am

Parser for determining Google Position

Post by visionmaster »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hello together,

I wrote a PHP parser which takes a searchword as input and outputs the position and page no. of my webpage found in the google result page. Everything works fine, but strangely my parser often outputs a different result than a direct search does for a product in google. My parser may show position 2 for a search word, whereas searching via browser, my webpage is placed at position 4. How can that be? Does google determine some client variables and therefore shows another result page? Any ideas how I can solve this problem?

Code: Select all

<?php $string = getPageUsingCurl("http://www.google.de/search?num=100&hs=T2D&hl=de&client=firefox-a&rls=org.mozilla%3Ade%3Aofficial&q=."$strSearchstring".&btnG=Suche&meta=lr%3Dlang_de");

/*********************************************************************
Funktion: Get's a web page into a string using the cURL library
Eingabe : URL
Ausgabe : String
*********************************************************************/   
function getPageUsingCurl($url) { 
   $ch = curl_init($url); 
   
   curl_setopt ($ch, CURLOPT_URL, $url); 
   curl_setopt ($ch, CURLOPT_HEADER, 0); 
   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
   
   $result = curl_exec ($ch); 
   //Bei keinem Fehler ist ein leerer String Rückgabewert
   if( curl_error($ch) <> '')
   {
	  $string = curl_error($ch);
 
      $ret["exitcode"]=-1;	
      return $ret;
   }		  

   curl_close ($ch); 
   
   //Liefert den Inhalt der Webpage zurück
   return $result; 
} 
?>
Thanks,
visionmaster


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Does google determine some client variables and therefore shows another result page? Any ideas how I can solve this problem?
Google isn't one server, it's a cluster. Every request can be a slightly different result depending on the server you get. The further down the list you go usually the more dynamic it gets.
Post Reply