harvestData Sinifi <?PHP
/**
* - A Simple Meta Tag Harvester
*
* @author Ilyas Serter
* @version 1.0 - Sep 8, 2011
* @link http://www.lampdeveloper.org
*
*/
class metaTagHarvester
{
const KEYWORDS = '#<meta name="keywords" content="(.+)"(.{1,3})>#i';
const DESCRIPTION = '#<meta name="description" content="(.+)"(.{1,3})>#i';
const TITLE = '#<title>(.+)</title>#';
public $url;
public static function harvestAll($source)
{
$keywords = self::harvestKeywords($source);
$descriptions = self::harvestDescription($source);
$title = self::harvestTitle($source);
return array('title' => $title[1],'keywords' => $keywords[1],'description' => $descriptions[1]);
}
public static function harvestKeywords($source)
{
preg_match(self::KEYWORDS,$source,$match);
return $match;
}
public static function harvestDescription($source)
{
preg_match(self::DESCRIPTION,$source,$match);
return $match;
}
public static function harvestTitle($source)
{
preg_match(self::TITLE,$source,$match);
return $match;
}
}
?>Kullanimi <?PHP
include 'harvestData.php';
$harvester = new metaTagHarvester();
$source = file_get_contents('http://www.oxera.net');
var_dump($harvester->harvestAll($source));
?>Donen dizinin ciktisi array(3) { ["title"]=> string(65) "Web Development and SEO Services in Seattle - Oxera Web Solutions" ["keywords"]=> string(105) "seo,search engine optimization,web development,seattle,seattle seo service,seattle web design,seattle seo" ["description"]=> string(105) "Looking for web development and SEO services in Seattle? Come right in, and see what Oxera offers to you!" }