I want to get the results from youtube trends hot videos : http://www.google.com.tr/trends/hotvideos#geo=CA&hvsm=1 I am using curl.
function cek($ursa){
$useragent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
$referer = 'http://www.google.com/';
$ch = curl_init();
$zaman = 0;
curl_setopt ($ch, CURLOPT_URL, $ursa);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $zaman);
curl_setopt ($ch, CURLOPT_REFERER, $referer);
curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
$rmx = curl_exec($ch);
curl_close($ch);
return $rmx;
}
$html = cek("http://www.google.com.tr/trends/hotvideos#geo=CA&hvsm=1");
echo $html;
When i get the page with curl i don't see video links in the page. How can i get them? I've looked on youtube api but couldn't find a way to get these results. Is there a way to get these results from Youtube api?
The videos do not appear because they are loaded with javascript, which is not executed by curl. I don't know about the youtube api, but to get the data from the website you will need to analyze the javascript it uses and replicate the requests it makes.