/ Published in: PHP
URL: http://www.barattalo.it/2010/01/12/bot-that-retrieves-url-meta-data-info/
From a given url this function retrieves page title, meta description, keywords, favicon, and an array of images to use for links. It call filegetcontents and then make some regular expression job.
Expand |
Embed | Plain Text
print_r(getLinksInfo("http://www.rockit.it/articolo/825/nada-studio-report-quando-nasce-una-canzone")); function getLinksInfo($url) { $data['keywords']=""; $data['description']=""; $data['title']=""; $data['favicon']=""; $data['title'] = $title_array[2][0]; for($i=0;$i<count($meta_array[0]);$i++) { if (strtolower(attr($meta_array[0][$i],"name"))=='description') $data['description'] = attr($meta_array[0][$i],"content"); if (strtolower(attr($meta_array[0][$i],"name"))=='keywords') $data['keywords'] = attr($meta_array[0][$i],"content"); } for($i=0;$i<count($link_array[0]);$i++) { if (strtolower(attr($link_array[0][$i],"rel"))=='shortcut icon') $data['favicon'] = makeabsolute($url,attr($link_array[0][$i],"href")); } for($i=0;$i<count($imgs_array[0]);$i++) { if ($src = attr($imgs_array[0][$i],"src")) { $src = makeabsolute($url,$src); } } $data['images']=$imgs; return $data; }
You need to login to post a comment.
