/ Published in: PHP
From a given url this function retrieves page title, meta description, keywords, favicon, and an array of images to use for links. It call file_get_contents and then make some regular expression job.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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]; 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"); } if (strtolower(attr($link_array[0][$i],"rel"))=='shortcut icon') $data['favicon'] = makeabsolute($url,attr($link_array[0][$i],"href")); } if ($src = attr($imgs_array[0][$i],"src")) { $src = makeabsolute($url,$src); } } $data['images']=$imgs; return $data; }
URL: http://www.barattalo.it/2010/01/12/bot-that-retrieves-url-meta-data-info/