среда, 5 сентября 2012 г.

Get Meta Tags php

Get meta tags from url, php function example:

function get_meta_tags ($url){
$html = load_content ($url,false,"");
print_r ($html);
preg_match_all ("/<title>(.*)<\/title>/", $html["content"], $title);
preg_match_all ("/<meta name=\"description\" content=\"(.*)\"\/>/i", $html["content"], $description);
preg_match_all ("/<meta name=\"keywords\" content=\"(.*)\"\/>/i", $html["content"], $keywords);
$res["content"] = @array("title" => $title[1][0], "descritpion" => $description[1][0], "keywords" =>  $keywords[1][0]);
$res["msg"] = $html["msg"];
return $res;
}

Example:

print_r (get_meta_tags ("bing.com") );

Комментариев нет:

Отправить комментарий