提问人:btgen 提问时间:6/29/2018 最后编辑:btgen 更新时间:6/29/2018 访问量:602
从 HTML5Player 外部源获取特定变量
get specific variable from html5player external source
问:
我正在尝试从呈现如下的外部源获取 var:html5player.setVideoUrlHigh
<script>
logged_user = false;
var static_id_cdn = 2;
var html5player = new HTML5Player('html5video', '38295'); //this is the video ID
if (html5player) {
html5player.setVideoTitle('video title goes here');
html5player.setVideoUrlHigh('https://random-prefix-here.site-url.com/videos/mp4/random-part-of-url');
...
}
</script>
首先,我获取嵌入代码:file_get_contents
$videoID = 38295;
$url = file_get_contents('https://www.site-url.com/embedframe{$videoID}');
然后,我寻找一个包含特定部分(如 (site-url.com/videos/mp4/))的 url 匹配来生态它,如下所示:
preg_match('/https:\/\/[^\"]*/\.site-url\.com\/videos\/mp4\/[^\"]*/', $url, $matches, PREG_OFFSET_CAPTURE);
$videoURL = ($matches[0][0]);
echo '=>' . $videoURL;
但这行不通......我在哪里失败了?
请记住,在可能的解决方案中,两者都应替换为正则表达式。random-prefix-here
random-part-of-url
更新
我也已经尝试过了,没有任何结果:
$url = 'http://www.site-url.com/embedframe38295/';
$content= file_get_contents($url);
preg_match_all('#html5player.setVideoUrlHigh\((.+?)\')', $url, $matches, PREG_OFFSET_CAPTURE);
$videoURL = ($matches[0][0]);
echo $videoURL;
答: 暂无答案
评论
html5player.setVideoUrlHigh('
');
$getVideoUrlHigh = "#html5player.setVideoUrlHigh\((.+?)\);";
'
'url'
url