【发布时间】:2016-09-15 12:41:42
【问题描述】:
我正在尝试从其他网站获取视频和海报 让我们称之为 othersite.com
其他 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 url
$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 正在获取图像,只有你知道我在 preg_match 中做错了什么以及如何获得http://othersite.com/video.mp4
【问题讨论】:
-
您的来源中没有
controls。您也不应该使用正则表达式来解析 HTML/XML。
标签: php preg-match file-get-contents