本文共 1565 字,大约阅读时间需要 5 分钟。
一、搜索歌曲API
http:
//musicmini.baidu.com/app/search/searchList.php?qword={0}&ie=utf-8&page={1}
{0}=需要搜索的歌曲或歌手
{1}=页码数(第一页就是0,第二页是1)
返回的是一个html网页,需要分析网页,得到歌曲ID,歌曲名,歌手,专辑等 属性
二、获取歌曲详细信息API
http:
//ting.baidu.com/data/music/links?songIds={0}
{0}=从上面的结果的中分析的歌曲的ID
{ "SongID": "14795583", "SongName": "海阔天空", "ArtistID": "82367", "ArtistName": "黄家驹", "AlbumID": "14686304", "AlbumName": "来自天堂的声音-黄家驹", "SongPicSmall": "http://musicdata.baidu.com/data2/pic/4ee18a5c97435ff5c883b25d9960c0af/262388741/262388741.jpg", "SongPicBig": "http://musicdata.baidu.com/data2/pic/b8aecedd9f9ca87f6298d76c8e1b73de/262388734/262388734.jpg", "SongPicRadio": "", "LrcLink": "http://musicdata.baidu.com/data2/lrc/d8e0550f18cebfebc6cbc30379ac9b64/262236886/262236886.lrc", "Version": "混音", "Time": 322, "LinkCode": "22000", "SongLink": "http://file.qianqian.com//data2/music/120871889/120871889.mp3?xcode=ce20e423fde9a5850c0d8753917afb85&src=\"http%3A%2F%2Fpan.baidu.com%2Fshare%2Flink%3Fshareid%3D551361339%26uk%3D1079230802\"", "ShowLink": "http://pan.baidu.com/share/link?shareid=551361339&uk=1079230802", "Format": "mp3", "Rate": "128", "Size": 5162937, "RelateStatus": "0", "ResourceType": "2", "Source": "web"}
里面有歌曲图片,歌曲地址,歌词地址
歌曲地址里如果有http:
//qukufile2.qianqian.com/data2/pic/和http://c.hiphotos.baidu.com/ting/pic/item/ 那就需要将http://c.hiphotos.baidu.com/ting/pic/item/给去掉
歌词地址:http:
//qukufile2.qianqian.com+获取到的url
使用到两个重要工具
1.Json序列化工具Newtonsoft.Json
2.Html解析工具:HtmlAgilityPack
源代码参考:
参考文章:
转载地址:http://dbogi.baihongyu.com/