找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 996|回复: 10

[iptv信源 资源分享或寻求] 利用PHP随机获取酷狗MV播放列表

[复制链接]
发表于 2022-9-7 22:55 | 显示全部楼层 |阅读模式
本帖最后由 hzl88688 于 2022-10-11 21:21 编辑

<?php
        $p=rand(1,2);
        $mvurl = "http://www.kugou.com/mvweb/html/index_13_".$p.".html";
        $data = curl_get($mvurl);
                  preg_match('/class="mvlist">(.*?)<\/div>/is',$data,$mvlist);
                  preg_match_all('/src="(.*)"/', $mvlist[1], $img);
                for($i = 0; $i < 20; $i++){
                         $mpic = $img[1][$i];
                        $hash = substr(strrchr($mpic,"/"),1,32);
                        $x_url = "http://m.kugou.com/app/i/mv.php?cmd=100&ext=mp4&hash=". $hash;
                   $data = curl_get($x_url);
                  preg_match('/songname":"(.*?)",/is', $data, $nm);
                preg_match_all('/backupdownurl":\["(.*?)"\]/is', $data, $bmp4);
   if(!empty(stripslashes($bmp4[1][2]))){
  echo  '#EXTINF:-1 group-title="酷狗MV",'.$nm[1];
         echo  '<br/>' ;
         echo  stripslashes($bmp4[1][2]);
         echo  '<br/>' ;
       }      
  }
        
function curl_get($url){
        $temp = parse_url($url);
        $header = array (
        "Host: {$temp['host']}",
        "Referer: http://{$temp['host']}/"
        );
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_USERAGENT, $Agent);
        curl_setopt($ch, CURLOPT_COOKIE,$Cookie);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    $output = curl_exec($ch);
    curl_close($ch);
return $output;
}        
        ?>


我的恩山、我的无线 The best wifi forum is right here.
发表于 2022-9-7 23:08 | 显示全部楼层
感谢楼主分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-9-7 23:18 | 显示全部楼层
本帖最后由 jiteloozz 于 2022-9-7 23:48 编辑

感谢分享,学习了~~~

$id的值就是$hash的值,为何要多做操作?

$hash = substr(strrchr($mpic,"/"),1,32);
/***********************************
$href = str_replace("=","",base64_encode("mv$".$hash));
$de64 = base64_decode($href);
$expl = explode('$',$de64);
$id = $expl[1];
**********************************/
$x_url = "http://m.kugou.com/app/i/mv.php?cmd=100&ext=mp4&hash=".$id;

这句直接写成  $x_url = 'http://m.kugou.com/app/i/mv.php?cmd=100&ext=mp4&hash='.$hash ; 应该可以吧?



我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-9-8 00:05 | 显示全部楼层
严格讲,循坏次数多了一次。
每个页面默认20个MV,即count($name[1])或count($img[1])
所以,
$n=count($name[1]);
for($i = 0; $i < $n; $i++){

点评

谢谢指点!  详情 回复 发表于 2022-9-8 16:14
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-9-8 09:21 | 显示全部楼层
获取后如何自动播放呢。diyp

点评

可以写好m3u文件  详情 回复 发表于 2022-9-8 16:14
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-9-8 16:14 | 显示全部楼层
jiteloozz 发表于 2022-9-8 00:05
严格讲,循坏次数多了一次。
每个页面默认20个MV,即count($name[1])或count($img[1])
所以,

谢谢指点!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-9-8 16:14 | 显示全部楼层
daneilzhou 发表于 2022-9-8 09:21
获取后如何自动播放呢。diyp

可以写好m3u文件

点评

如何操作呢?  详情 回复 发表于 2022-9-8 16:34
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-9-8 16:34 | 显示全部楼层
hzl88688 发表于 2022-9-8 16:14
可以写好m3u文件

如何操作呢?

点评

echo '#EXTINF:-1 group-title="酷狗MV",'.$nm[1]; echo '' ; echo stripslashes($bmp4[1][2]); echo '' ; 把上述几行用file_put_contents写入M3U文件,应可以。  详情 回复 发表于 2022-9-8 16:44
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-9-8 16:44 | 显示全部楼层

echo  '#EXTINF:-1 group-title="酷狗MV",'.$nm[1];
         echo  '<br/>' ;
         echo  stripslashes($bmp4[1][2]);
         echo  '<br/>' ;

把上述几行用file_put_contents写入M3U文件,应可以。

点评

好的。 谢谢  详情 回复 发表于 2022-9-9 16:09
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-9-9 16:09 | 显示全部楼层
hzl88688 发表于 2022-9-8 16:44
echo  '#EXTINF:-1 group-title="酷狗MV",'.$nm[1];
         echo  '' ;
         echo  stripslashes ...

好的。 谢谢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-10-11 21:22 | 显示全部楼层
酷狗对页面作了限制了!不能随机获取了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-26 04:27

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表