从html5player外部源获取特定变量

时间:2018-06-28 18:38:44

标签: php

我正试图从呈现如下的外部源中获取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-hererandom-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;

0 个答案:

没有答案