To get the title and meta tags from a website you can use the following code :
<html>
<head>
</head>
<body>
<?php
function getTitle($Url){
$str = file_get_contents($Url);
if(strlen($str)>0){
preg_match("/\<title\>(.*)\<\/title\>/",$str,$title);
return $title[1];
}
}
//Example:
echo 'TITLE :'.getTitle("http://www.cnn.com");
// Assuming the above tags are at www.cnn.com
$tags = get_meta_tags('http://www.whoznext.com/')
or die("Could not fetch meta tags");
// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo 'AUTHOR '.$tags['author'].'<br/>'; // name
echo 'KEYWORDS '.$tags['keywords'].'<br/>'; // php documentation
echo 'Description '.$tags['description'].'<br/>'; // a php manual
echo 'Location '.$tags['geo_position'].'<br/>'; // 49.33;-86.59
?>
Test!
</body>
</html>
OUTPUT:
TITLE :CNN.com International - Breaking, World, Business, Sports, Entertainment and Video News
AUTHOR:
KEYWORDS
CNN, CNN news, CNN International, CNN International news, CNN Edition, Edition news, news, news online, breaking news, U.S. news, world news, global news, weather, business, CNN Money, sports, politics, law, technology, entertainment, education, travel, health, special reports, autos, developing story, news video, CNN Intl, podcasts, world blogs
Description CNN.com International delivers breaking news from across the globe and information on the latest top stories, business, sports and entertainment headlines. Follow the news as it happens through: special reports, videos, audio, photo galleries plus interactive maps and timelines.
Location
0 Comment(s)