【问题标题】:PHP fetch with file_get_contents() funtion使用 file_get_contents() 函数获取 PHP
【发布时间】:2017-09-12 08:34:20
【问题描述】:

我想在其他 php 页面上从此站点获取 m3u8 链接

例如:这是网站:“view-source:http://lideo.ru/embed/9528

我只想将此 m3u8 提取到其他 php 页面:http://hls.lideo.ru/liveapp/09528_bd608448e6c4a218d16b1f7b4018f6e8/index.m3u8?tokenhash=TIai4tLuWZHdLOS5mjNOqw

我试过这段代码,但似乎不起作用

$url = "http://lideo.ru/embed/9528";
$contents = file_get_contents($url);

preg_match('@m3u8([^"]+)@',$contents,$rtmp);
$link = urldecode($link[0]);
echo $link;

任何帮助,因为我在 php 方面不太好 :)

谢谢

【问题讨论】:

  • 你得到了什么
  • 我只得到一个白页,我认为我的代码是错误的,因为我在 php 方面不太好,你能帮帮我吗
  • '@m3u8([^"]+)@' 让您看起来像是在尝试将其读取为 XML。您需要在 DOM 文档中导入 URL 并使用 XPATH 来获取价值
  • 这里的变量名问题。 $link[0] 必须是 $rtmp[0]

标签: php json preg-match fetch file-get-contents


【解决方案1】:

试试这个:

$url = "http://lideo.ru/embed/9528";
$contents = file_get_contents($url);

preg_match('/(https?\:\/\/[^\']*\.m3u8\?[^\']*)/', $contents, $result);
$link = urldecode($result[0]);
echo $link;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-27
    • 2014-05-20
    • 1970-01-01
    • 2011-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多