<?php
function getUrl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $U);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
preg_match('/Location:(.*?)\n/', $res, $matches);
return trim(array_pop($matches));
}
$id_imdb = 'tt0499549';
$ch = curl_init('http://www.imdb.com/title/'.$id_imdb.'/');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.imdb.com/');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36');
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Accept-Language: en'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$results = curl_exec($ch);
curl_close($ch);
preg_match_all('(Official Sites:</h4>(.*)Official site</a>)siU', $results, $official);
preg_match_all('(<a href=\"(.*)\')siU', $official[1][0], $oficial);
for($o = 0; $o < count($oficial[1]); $o++){
$url_oficial = 'http://www.imdb.com/'.$oficial[1][$o];
echo getUrl($url_oficial);
}
?>