我試着從其他網站獲取 視頻和海報讓我們把它叫做othersite.com如何使用的file_get_contents在PHP
其他site.com將視頻網址有這個參數:
<div class="player">
<div id="l_player" class='l-player' >
<noscript>
<video style="width:100%; height:100%;"
controls="controls"
autobuffer="autobuffer"
class="player-html5"
preload="metadata"
poster="http://othersite.com/img.jpg">
<source src="http://othersite.com/video.mp4" type="video/mp4">
</video>
</noscript>
</div>
與下面的PHP我從opengraph標籤的圖像,但是我試着讓MP4的網址,我不可能得到尚未
$Agent = array('http' => array('user_agent' => 'Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D)'));
$String = file_get_contents('http://www.othersite.com/'. $video .'/', false, stream_context_create($Agent));
preg_match("/<source src=\"(.*)\" controls type=\"video\/mp4\"/", $String, $VideoURL);
$VideoURL = $VideoURL[1];
$IMG = getstring($String,'<meta property="og:image" content="','"');
我的PHP越來越像只做你有什麼想法w ^帽子我在preg_match中做錯了以及如何獲得http://othersite.com/video.mp4
源代碼中沒有'controls'。你也不應該使用正則表達式來解析HTML/XML。 – chris85