找到周杰倫所有歌曲的 歌曲名、所屬專輯、播放時長,播放連結
URL https://c.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.song&searchid=59511865801247509&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=1&n=10&w=%E5%91%A8%E6%9D%B0%E4%BC%A6&g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0
1 #8 尋找周杰倫 2 # 找到周杰倫所有歌曲的 歌曲名、所屬專輯、播放時長,播放連結 3 # URL https://c.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.song&searchid=59511865801247509&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=1&n=10&w=%E5%91%A8%E6%9D%B0%E4%BC%A6&g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0 4 5 import requests 6 from bs4 import BeautifulSoup 7 res = requests.get('https://c.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.song&searchid=59511865801247509&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=1&n=10&w=%E5%91%A8%E6%9D%B0%E4%BC%A6&g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0') 8 html = res.json() 9 music_list = html['data']['song']['list'] 10 total_num = html['data']['song']['totalnum'] 11 total_page = int(total_num / 10) + 1 12 #print(total_page) 13 gequid= 0 14 for pages in range(1,total_page): 15 res = requests.get('https://c.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.song&searchid=59511865801247509&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p={}&n=10&w=%E5%91%A8%E6%9D%B0%E4%BC%A6&g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0'.format(pages)) 16 html = res.json() 17 music_list = html['data']['song']['list'] 18 for i in range(len(music_list)): 19 gequid = gequid + 1 20 print(gequid,end='\t') 21 print(music_list[i]['name'],end='\t') 22 print(music_list[i]['album']['name'],end='\t') 23 print(music_list[i]['interval'],end='\t') 24 print(music_list[i]['url']) 25 26 ''' 27 執行結果如下: 28 1 晴天 葉惠美 269 http://stream10.qqmusic.qq.com/97773.wma 29 2 告白氣球 周杰倫的床邊故事 215 http://stream10.qqmusic.qq.com/107192078.wma 30 3 稻香 魔傑座 223 http://stream10.qqmusic.qq.com/449205.wma 31 4 不能說的祕密 不能說的祕密 電影原聲帶 296 http://stream10.qqmusic.qq.com/403778.wma 32 5 七里香 七里香 299 http://stream10.qqmusic.qq.com/102065756.wma 33 6 青花瓷 我很忙 239 http://stream10.qqmusic.qq.com/410316.wma 34 7 簡單愛 范特西 271 http://stream10.qqmusic.qq.com/97744.wma 35 8 等你下課(with 楊瑞代) 等你下課 270 http://stream10.qqmusic.qq.com/212877900.wma 36 9 夜曲 十一月的蕭邦 226 http://stream10.qqmusic.qq.com/718477.wma 37 10 彩虹 我很忙 263 http://stream10.qqmusic.qq.com/102340966.wma 38 39 351 布拉格廣場 愛的藉口(新歌+精選) 301 http://stream10.qqmusic.qq.com/131385.wma 40 352 龍捲風 地表最強 - 周杰倫 249 http://stream10.qqmusic.qq.com/203466849.wma 41 353 最長的電影 地表最強 - 周杰倫 238 http://stream10.qqmusic.qq.com/203466850.wma 42 354 明明就 地表最強 - 周杰倫 259 http://stream10.qqmusic.qq.com/203466848.wma 43 355 紅塵客棧 明日之子 第12期 239 http://stream10.qqmusic.qq.com/203761067.wma 44 356 黑色幽默 夢想的聲音 第4期 290 http://stream10.qqmusic.qq.com/109394038.wma 45 46 '''