$name为输出歌曲名字
复制代码 代码如下:
<?php
error_reporting(0);
function ConvertUrlEncode($text)
{
$textUrl = htmlspecialchars(urlencode($text));
return $textUrl;
}
$Type=substr($name,-4);
$name1=str_replace($Type,"",$name);
$name2=str_replace("-","",$name1);
$uk=ConvertUrlEncode($name2);
$str=file_get_contents('http://music.baidu.com/search/lrc?key='.$uk);
preg_match_all('/<p id="lyricCont-0">(.*?)<\/p>/is',$str, $arr);
foreach ($arr[1] as $k => $v){
}
if($v){
echo $v;
}else{
echo '很抱歉,百度都没找到'.$name.'的歌词,这歌曲也太给力了吧~!';
}
?>
时间: 2024-10-11 17:32:38