快手热播榜前十排行榜API接口源码,调用的快手官方数据接口,返回热播榜前十的JSON格式数据。
<?php $header="User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0"; $options['http'] = array( 'method' => "GET", 'header' => $header); $context = stream_context_create($options); ini_set('allow_url_fopen','on'); ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'); $text = file_get_contents("https://www.kuaishou.com/",1,$context); preg_match_all('#<p class="rank-name" data-v-0b3dceae>([^"]*?)<#',$text,$name); preg_match_all('#<span class="hot-value" data-v-0b3dceae data-v-5d4cbc17>([^"]*?)</span>#',$text,$hot); $out = array( "top_1" => array( "name" => urldecode($name[1][0]), "hot" => $hot[1][0] ), "top_2" => array( "name" => $name[1][1], "hot" =>$hot[1][1] ), "top_3" => array( "name" => $name[1][2], "hot" => $hot[1][2] ), "top_4" => array( "name" => $name[1][3], "hot" =>$hot[1][3] ), "top_5" => array( "name" => $name[1][4], "hot" => $hot[1][4] ), "top_6" => array( "name" => $name[1][5], "hot" => $hot[1][5] ), "top_7" => array( "name" => $name[1][6], "hot" => $hot[1][6] ), "top_8" => array( "name" => $name[1][7], "hot" => $hot[1][7] ),"top_9" => array( "name" => $name[1][8], "hot" => $hot[1][8] ),"top_10" => array( "name" =>$name[1][9], "hot" => $hot[1][9] )); #$out = str_replace("data-v-0b3dceae>",'',$out); #$wb ='<p class="rank-name" data-v-0b3dceae>abc</p>'; # $out=wb_qzj($wb,'<p class="rank-name" data-v-0b3dceae>','</p>'); header('Content-type:text/json'); echo json_encode($out,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);