Mit dem folgenden PHP-Code kann man sich die Position einer Seite bei einem bestimmten Keyword anzeigen. Das Snippet wurde entwickelt um die Entwicklung einiger Seiten automatisiert zu speichern und auszuwerten.

class base
{

	function crawlUrl($url)
	{

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
		curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204");
		if (!($contents = trim(@curl_exec($ch)))) {
			$this->debugRes("error","curl_exec failed");
		}
		curl_close ($ch);

		return $contents;

	}
}

function getPosition($keyword,$url)
{

	$googleurl = 'http://www.google.de/search?num=100&q=' . urlencode($keyword);
	$content = base::crawlUrl($googleurl);

	preg_match_all('/a href="([^"]+)" class=l.+?>.+?<\/a>/',$content,$ra);

	foreach ($ra[1] as $google)
	{
		$google = preg_replace('(^http://|/$)','',$google);
		@$position++;
		if ($google==$url)
		{
			$keyposition=$position;
			break;
		}
	}

return $keyposition;

}

echo getPosition("simon frerichs","www.morphhome.net");

Related posts:

  1. Google Suggestions in Keyword Applikation integrieren
  2. Seiten im Google Index mit PHP+Curl anzeigen
  3. Backlinks bei Google mit PHP+Curl auslesen
  4. Code to Text Ratio mit PHP ausrechnen
  5. Seitwert Daten in Applikation integrieren