分享菜鸟级的PHP采集教程与视频解析,HTML代码模板免费资源分享平台

php采集QQ音乐歌手列表

02 08月
作者:七哥| 分类:生活随笔| 发布时间:2017年08月02日 |标签:列表采集php QQ音乐采集

用到cmp4会玩的都会用,不作说明了。可以参考http://blog.0735dj.com/qfdj.html 下面是PHP代码

<?php
error_reporting(0);
header("Content-type:text/xml;charset=utf-8");
$fname = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER["SCRIPT_NAME"];
$keystr = CURL("http://c.y.qq.com/base/fcgi-bin/fcg_musicexpress.fcg?json=3&guid=3318398504&g_tk=5381&jsonpCallback=jsonCallback&loginUin=398875636&hostUin=0&format=jsonp&inCharset=utf8&notice=0&platform=yqq&needNewCode=0");
preg_match('#jsonCallback\((.*)\)#', $keystr, $js);
$json = json_decode($js[1], true);
$sip = $json['sip'][0];
$vkey = $json['key'];
define("sip", $sip);
define("vkey", $vkey);
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$xml = "<list>\n";
if (isset($_GET['type']) && isset($_GET['page'])) {
 $dourl = "https://c.y.qq.com/v8/fcg-bin/v8.fcg?channel=singer&page=list&key=" . $_GET['type'] . "_all&pagesize=100&pagenum=" . $_GET['page'] . "&format=jsonp";
 $curl = str_ireplace("&", "", CURL($dourl));
 $json = json_decode($curl);
 $list = $json->data->list;
 for ($i = 0; $i < count($list); $i++) {
        $xml.= '<m list_src="' . $fname . '?mid=' . $list[$i]->Fsinger_mid . '" label="' . $list[$i]->Fsinger_name . '" />' . PHP_EOL;
    }
} elseif (isset($_GET['type'])) {
    $dourl = "https://c.y.qq.com/v8/fcg-bin/v8.fcg?channel=singer&page=list&key=" . $_GET['type'] . "_all&pagesize=100&pagenum=1&format=jsonp";
    $curl = str_ireplace("&", "", CURL($dourl));
    $json = json_decode($curl);
    $total_page = $json->data->total_page;
    if ($total_page > 1000) $total_page = 1000;
    for ($i = 0; $i < $total_page; $i++) {
        $xml.= '<m list_src="' . $fname . '?type=' . $_GET['type'] . '&page=' . ($i + 1) . '" label="第' . ($i + 1) . '页" />' . PHP_EOL;
    }
} elseif (isset($_GET['mid'])) {
    $dourl = "https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg?singermid=" . $_GET['mid'] . "&order=listen&begin=0&num=500";
    $curl = str_ireplace("&", "", CURL($dourl));
    $json = json_decode($curl);
    $list = $json->data->list;
    for ($i = 0; $i < count($list); $i++) {
        if ($list[$i]->musicData->songmid) $xml.= '<m src="' . sip . $list[$i]->musicData->songid . '.m4a?vkey=' . vkey . '&guid=3318398504" label="' . $list[$i]->musicData->songname . '" />' . PHP_EOL;
    }
} else {
    $dourl = "https://y.qq.com/portal/singer_list.html";
    $curl = str_ireplace("&", "", CURL($dourl));
    preg_match('/js_area">(.*)<\/div>/imsU', $curl, $div);
    preg_match_all('/data\-key="(.*)" hidefocus>(.*)<\/a>/imsU', $div[1], $data_key);
    foreach ($data_key[1] as $key => $val) {
        $xml.= '<m list_src="' . $fname . '?type=' . $data_key[1][$key] . '" label="' . $data_key[2][$key] . '" />' . PHP_EOL;
    }
}
$xml.= "</list>";
echo $xml;
function CURL($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
?>
   

浏览150 评论0
返回
目录
返回
首页
解析斗鱼直播采集php代码8/1更新 湖南卫视在线直播,七哥博客

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。