Da immer mal wieder über das Code zu Text Ratio diskutiert wird, habe ich das folgende kleine Tool gebaut. Die Auswertung ist nicht 100% genau und optimal realisiert, reicht aber um einen Eindruck zu bekommen, wie das Verhältnis ist.

Wieder einmal wichitg: 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;

	}
}

class htmltotextratio
{

	function getRatio($domain)
	{

		$content=base::crawlUrl("http://".$domain);

		$strc1=strlen($content);
		$content = preg_replace("'XXXstyle[^>]*>.*XXX/style>'siU",'',$content);
		$strc2=strlen(trim(strip_tags($content)));

		$ratio=($strc2/$strc1*100);

		return $ratio;

	}

}

$htmltotextratio=new htmltotextratio;
echo $htmltotextratio->getRatio("www.morphhome.net");

Related posts:

  1. Seiten im Google Index mit PHP+Curl anzeigen
  2. Position einer Seite bei Keyword zeigen
  3. Backlinks bei Google mit PHP+Curl auslesen
  4. Google Suggestions in Keyword Applikation integrieren
  5. Backlinks und Seitenanzahl über den Yahoo Siteexplorer auslesen