[英]Regex: How to grab wmsAuthSign for stream file (m3u8)?
我目前正在使用 PHP 正則表達式代碼,它為特定站點獲取令牌 wmsAuthSign=*,每個令牌有效期為 30 分鍾。
<?php
$streamSite = "https://www.liveonlinetv247.info/embed/cartoonnetwork.php";
function writeFile($url, $channel) {
$File = $channel.".strm";
$Handle = fopen($File, 'w');
fwrite($Handle, $url);
fclose($Handle);
}
$input = @file_get_contents($streamSite) or die("Please try again later: $url");
preg_match("/(http.*?wmsAuthSign\=[^\&\">]+)/", $input, $matches);
echo $matches[1];
效果很好,但現在我想知道如何為直接 URL 創建正則表達式:(沒有 PHP 網站)
https://freeeucache2.streamlive.to/live/2tag4dzgwof5ma2/chunks.m3u8?nimblesessionid=6976110&wmsAuthSign=c2VydmVyX3RpbWU9MTIvMTkvMjAxNyA3OjM1OjI5IEFNJmhhc2hfdmFsdWU9QlJDV1lCTzRKbnVaWEIvZDhmNURndz09JnZhbGlkbWludXRlcz0zMCZzdHJtX2xlbj0yMA==
我附上了最后一個令牌 wmsAuthSign=*。
Base64 解碼:
server_time=12/19/2017 7:35:29 AM&hash_value=BRCWYBO4JnuZXB/d8f5Dgw==&validminutes=30&strm_len=20
為這個 URL 創建正則表達式有哪些選項?
您好親愛的您能幫我為什么它不起作用我希望您能幫助我
<?php $streamSite = "http://m.liveonlinetv.org/external.php?title=Willow%20TV&stream=willow-hq"; function writeFile($url, $channel) { $File = $channel.".strm"; $Handle = fopen($File, 'w'); fwrite($Handle, $url); fclose($Handle); } $input = @file_get_contents($streamSite) or die("Please try again later: $url"); preg_match("/(http.*?wmsAuthSign=[^&">]+)/", $input, $matches); $wmsAuthSignKv = parse_url($matches[1], PHP_URL_QUERY); $wmsAuthSign = explode('=', $wmsAuthSignKv); echo $wmsAuthSign[1] . "<br>"; $m3u8 = parse_url($matches[1], PHP_URL_PATH); echo basename($m3u8) . "<br>"; ?>
這將獲得第 1 組中的令牌:
wmsAuthSign=([^&?]+)$
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.