
If you want to make a project such as scraping or digg submit url, here are some PHP functions that can be used:
1. How to Scrape Meta Tags From Any Web Page With PHP
[php]
function getMetaData($url){
// get meta tags
$meta=get_meta_tags($url);
// store page
$page=file_get_contents($url);
// find where the title CONTENT begins
$titleStart=strpos($page,’<title>’)+7;
// find how long the title is
$titleLength=strpos($page,’</title>’)-$titleStart;
// extract title from $page
$meta['title']=substr($page,$titleStart,$titleLength);
// return array of data
return $meta;
}
$tags=getMetaData(‘http://www.yahoo.com/’);
echo ‘Title: ‘.$tags['title'];
echo ‘<br />’;
echo ‘Description: ‘.$tags['description'];
echo ‘<br />’;
echo ‘Keywords: ‘.$tags['keywords'];
[/php]
Source : http://webhole.net/2010/02/21/how-to-extract-meta-data-from-a-page/
2. Digg Like URL Submitter Using JQuery and PHP
[php]
function getMetaTitle($content){
$pattern = "|<[\s]*title[\s]*>([^<]+)<[\s]*/[\s]*title[\s]*>|Ui";
if(preg_match($pattern, $content, $match))
return $match[1];
else
return false;
}
$url = $_POST['url'];
$data = array();
// get url title
$content = @file_get_contents($url);
$data['title'] = getMetaTitle($content);
// get url description from meta tag
$tags = @get_meta_tags($url);
$data['description'] = $tags['description'];
echo json_encode($data);
[/php]
3. PHP function get_meta_tags ()
[php]
// Assuming the above tags are at www.example.com
$tags = get_meta_tags(‘http://www.example.com/’);
// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo $tags['author']; // name
echo $tags['keywords']; // php documentation
echo $tags['description']; // a php manual
echo $tags['geo_position']; // 49.33;-86.59
[/php]

