我想從YouTube視頻中獲得結果熱門視頻: http://www.google.com.tr/trends/hotvideos#geo=CA&hvsm=1 我正在使用捲曲。使用php curl獲取YouTube視頻流行趨勢熱門視頻的結果
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;
當我得到頁面捲曲我沒有看到頁面中的視頻鏈接。 我怎樣才能得到他們?我已經看過YouTube的API,但無法找到獲得這些結果的方法。有沒有辦法從Youtube API獲得這些結果?
請求的結果是什麼? – Raptor 2015-03-25 04:24:42
@ Raptor:本網站不允許我添加它,因爲結果太長。結果如下:https://justpaste.it/k5nq – r10 2015-03-25 18:53:46
明白了。我注意到你沒有使用Youtube API。您應該使用API而不是獲取整個YouTube頁面的HTML源代碼。 – Raptor 2015-03-26 01:55:33