Ebenfalls für ein internes Projekt brauchte ich folgenden Code, der einem die Anzahl der im Google Index indizierten Seiten per “site:” ausliest.

Wichtig wie immer: XXX durch < ersetzen!

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 getPages($target)
{

  $content = strtolower(base::crawlUrl("http://www.google.de/search?hl=en&source=hp&q=site%3A".$target."&aq=f&aqi=&aql=&oq=&gs_rfai="));
  $content = strip_tags(preg_replace("'XXXstyle[^>]*>.*XXX/style>'siU",'',$content));
  $domain=str_replace("http://","",$target);

  $resultnew=str_replace("about ","",$content);
  $resultnew=substr($resultnew, strpos($resultnew, 'advanced search')+15);
  $resultnew=substr($resultnew, 0, strpos($resultnew, ' result'));

  return trim(str_replace(",","",$resultnew));

} 

echo getPages("http://www.morphhome.net");

Related posts:

  1. Backlinks bei Google mit PHP+Curl auslesen
  2. Google Suggestions in Keyword Applikation integrieren
  3. Position einer Seite bei Keyword zeigen
  4. Code to Text Ratio mit PHP ausrechnen
  5. Backlinks und Seitenanzahl über den Yahoo Siteexplorer auslesen