扒取***云歌单音乐

发布于:2020-08-08 17:24:30

<?php
    // $url = 'http://music.163.com';
 
    $url = "http://music.163.com/api/playlist/detail?id=997620367";//本人的收藏歌单
 
    function curl_get($url){
        $ch = curl_init();
 
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);     
 
        $result = curl_exec($ch);    
        curl_close($ch);
 
        return $result;
    }
 
    $result = curl_get($url);
 
    $arr = json_decode($result, true);
    $musicArr = [];
    foreach ($arr["result"]["tracks"] as $key => $value) {
        if($key < 50){
            $musicArr[$key]["song"] = $arr["result"]["tracks"][$key]["name"];
            $musicArr[$key]["songer"] = $arr["result"]["tracks"][$key]["artists"][0]["name"];
 
         
        }
        continue;
         
    }
 
    foreach ($musicArr as $k=>$v) {
        $chunk = explode(' ', $musicArr[$k]['songer']);
        $qian=array(" "," ","\t","\n","\r");  
        $musicArr[$k]['song'] = str_replace($qian, '', $musicArr[$k]['song']);   
        $mess = $musicArr[$k]['song'];
         
        $baiduUrl = "http://sug.music.baidu.com/info/suggestion?format=json&version=2&from=0&word=".$mess."&_=1405404358299";
        $sugg[] = json_decode(curl_get($baiduUrl), 'true');
    }
    $n = 0;
    foreach ($sugg as $key => $value) {
        if(!empty($value['data'])){
            $link = "http://ting.baidu.com/data/music/links?songIds=".$value['data']['song'][0]["songid"]."&format=json";
            $down_link = curl_get($link);
            $result = json_decode($down_link, true);
            if($result["errorCode"] == 22000){
                foreach ($result["data"]["songList"] as $row) {
                    # code...
                    if(!empty($row["songLink"])){
                        $data = curl_get($row["songLink"]);
                             file_put_contents('./wang/'.$row['songName'].'.mp3', $data);
                    }
                }
            }
        }
        $n++;
             
    }


阅读 93+

一片空白

父爱如山,不善表达。回想十多年前,总记得父亲有个宽厚的肩膀,小小的自己跨坐在上面,越过人山人海去看更广阔的天空,那个时候期望自己有一双翅膀,能够像鸟儿一样飞得高,看得远。虽然父亲有时会和自己开玩笑,但在做错事的时候会受到严厉的训斥。父亲有双粗糙的大手掌。