这是来自女巫的视频,我想获得og:title
http://www.youtube.com/watch?feature=player_embedded&v=A683kmvRH_8
php代码
function file_get_contents_curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$html = file_get_contents_curl($pageurl);
$doc = new DOMDocument();
@$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title');
$titleBackUp = $nodes->item(0)->nodeValue;
$metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++){
$meta = $metas->item($i);
if($meta->getAttribute('name') == 'title')
$title = $meta->getAttribute('content');
}
标题是Мастило - В ръцете ти е най-добре [HQ]我得到
С°ÑÑило - ÑÑÑеÑе Ñи е най-добÑе [总部]
我也尝试
curl_setopt( $ch, CURLOPT_ENCODING, "UTF-8" );
但它不起作用。
我尝试使用html_entity_decode但不工作