これは私が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]で、
ÐаÑÑило--ÐÑÑÑеÑеÑиенай-добÑе [HQ]
私もやってみます
curl_setopt( $ch, CURLOPT_ENCODING, "UTF-8" );
しかし、それはうまくいきません。
html_entity_decodeを試してみましたが、機能していません