指示在php中通过DOM获得的播放器路径
存在: 在服务器1内部,有一个带有Clappr的播放器,如下所示:指示在php中通过DOM获得的播放器路径,php,curl,dom,m3u8,clappr,Php,Curl,Dom,M3u8,Clappr,存在: 在服务器1内部,有一个带有Clappr的播放器,如下所示: <script type='text/javascript'> var player = new Clappr.Player({ source: window.atob("bXlzdHJlYW0ubTN1OA=="), plugins: [], parentId: '#player', width: '100%',
<script type='text/javascript'>
var player = new Clappr.Player({
source: window.atob("bXlzdHJlYW0ubTN1OA=="),
plugins: [],
parentId: '#player',
width: '100%',
height: '100%',
//hlsMinimumDvrSize: 0,
chromecast: {
appId: '9DFB77C0',
media: {
type: ChromecastPlugin.None,
title: 'Tittle',
subtitle: 'Sub'
}}
//playback: {
// hlsjsConfig: {
// liveSyncDurationCount: 2
//}
//}
});
// get $html with CURL...
// for example
$html = '<script>...window.atob("bXlzdHJlYW0ubTN1OA==")...';
// capture window.atob("....") inside a variable: $html_snip
preg_match('/(window\.atob\(\".*\"\))/', $html, $html_snip);
// transform it to array [0][window.atob(] [1][....] [2][)]
$html_snip = explode('"', $html_snip[0]);
// get the encoded part [1][...]
$encoded_link = $html_snip[1];
// decode it from base64 to "mystream.m3u8"
$real_link = base64_decode($encoded_link);
// Now you can use $real_link where you want
// A. save it in a file...
$save_path = "links.txt";
file_put_contents($save_path, $real_link);
// B. echo it inside a <script>
<script>
// javacript here....
var real_link = "<?php echo $real_link; ?>";
</script>
$url = 'http://server1.com/player.php';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10');
$html = curl_exec($curl);
curl_close($curl);
$dom = new DOMDocument();
@$dom->loadHTML($html); //convert character asing
$xpath = new DOMXPath($dom);
$script = $xpath->query ('//script[contains(text(),"window.atob(")]')->item (0)->nodeValue;
$json = end(explode( 'sources:', $script));
$json = explode ( ']', $json)[0].']';
echo $json
?>```
[1]: https://stackoverflow.com/a/44234560/12765259
要实现这一点,您应该查找以下PHP函数:和 然后像这样做:
<script type='text/javascript'>
var player = new Clappr.Player({
source: window.atob("bXlzdHJlYW0ubTN1OA=="),
plugins: [],
parentId: '#player',
width: '100%',
height: '100%',
//hlsMinimumDvrSize: 0,
chromecast: {
appId: '9DFB77C0',
media: {
type: ChromecastPlugin.None,
title: 'Tittle',
subtitle: 'Sub'
}}
//playback: {
// hlsjsConfig: {
// liveSyncDurationCount: 2
//}
//}
});
// get $html with CURL...
// for example
$html = '<script>...window.atob("bXlzdHJlYW0ubTN1OA==")...';
// capture window.atob("....") inside a variable: $html_snip
preg_match('/(window\.atob\(\".*\"\))/', $html, $html_snip);
// transform it to array [0][window.atob(] [1][....] [2][)]
$html_snip = explode('"', $html_snip[0]);
// get the encoded part [1][...]
$encoded_link = $html_snip[1];
// decode it from base64 to "mystream.m3u8"
$real_link = base64_decode($encoded_link);
// Now you can use $real_link where you want
// A. save it in a file...
$save_path = "links.txt";
file_put_contents($save_path, $real_link);
// B. echo it inside a <script>
<script>
// javacript here....
var real_link = "<?php echo $real_link; ?>";
</script>
//使用CURL获取$html。。。
//比如说
$html='…window.atob(“bXlzdHJlYW0ubTN1OA==”);
//在变量内捕获window.atob(“..”):$html\u snip
preg\u match('/(window\.atob\(\“*”)/”,$html,$html\u snip);
//将其转换为数组[0][window.atob(][1][..][2][)]
$html_snip=explode(“,$html_snip[0]);
//获取编码部分[1][…]
$encoded_link=$html_snip[1];
//将其从base64解码为“mystream.m3u8”
$real\u link=base64\u解码($encoded\u link);
//现在,您可以在需要的地方使用$real\u链接
//A.将其保存在文件中。。。
$save_path=“links.txt”;
文件内容($save\u path,$real\u link);
//B.在a内回声
//这里是Javascript。。。。
var real_link=“”;
我真正想做的是:“保存”网站服务器上文件中的流路径,这样当路径从“server1.com”更改时,它将在“server2.com”中继续工作