我想从youtube上的热门视频中获得结果:http://www.google.com.tr/trends/hotvideos#geo=CA&hvsm=1我正在使用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;当我使用curl获取页面时,我在页面中看不到视频链接。我怎样才能得到它们呢?我已经在youtube api上找过了,但找不到一种方法来获得这些结果。有没有办法从Youtube api中获取这些结果?
发布于 2015-03-25 12:54:13
视频不会出现,因为它们是用javascript加载的,而javascript不是由curl执行的。我不知道youtube api,但要从网站获取数据,你需要分析它使用的javascript,并复制它发出的请求。
https://stackoverflow.com/questions/29247403
复制相似问题