## 用途 ## 主要通过分享链接提取酷狗音乐hash的值。 ![微信图片_20210530115923.jpg][1] ![微信截图_20210530114953.png][2] ## 代码 ## ![微信截图_20210530114826.png][3] [hide] function kugou_hash($url) { //$url = 'https://t1.kugou.com/song.html?id=6a0Ax81xXV2'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_exec($ch); $info = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL); curl_close($ch); //return $info; if($info == $url){ return false; }else{ $lines = file($info); $linesss = ''; foreach ($lines as $line_num => $line) { $linesss .= htmlspecialchars($line); } preg_match_all('/\[{.*?\}]/', $linesss, $pat_array); $str = trim($pat_array[0][0],"[{"); $str = trim($str,"}]"); $str = explode(",",$str); $ss = $str[0]; $ss = explode(":",$ss); $isMatched = preg_match_all('/[A-Za-z0-9]{0,32}/', $ss[1], $hash); return $hash[0][3]; } } [button color="success" icon="" url="https://wwa.lanzoui.com/iSNs9plstoh" type=""]下载代码[/button] [/hide] [1]: https://www.lanhuiw.cn/usr/uploads/2021/05/1178311563.jpg [2]: https://www.lanhuiw.cn/usr/uploads/2021/05/2425788008.png [3]: https://www.lanhuiw.cn/usr/uploads/2021/05/3742709192.png 用途主要通过分享链接提取酷狗音乐hash的值。代码此处内容需要评论回复后(审核通过)方可阅读。 最后修改:2021 年 05 月 30 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏