import requests headers = { 'Accept': 'application/json, text/plain, */*', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Connection': 'keep-alive', 'Host': 'bd-api.kuwo.cn', 'Origin': 'https://h5app.kuwo.cn', 'Referer': 'https://h5app.kuwo.cn/', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-site', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', 'plat': 'h5', 'sec-ch-ua': '"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"', 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"Windows"' } url = 'https://bd-api.kuwo.cn/api/service/music/recommendList?fg=1&lock=0&lastColdStartTime=1707289395168&scrollNum=3&resourceId=6187940&recoMode=normal&source=0&sourceId=0&totalNum=3&uid=27743594&token=c8072e4563ec7604f9f96b1d2964303c×tamp=1707289428831&sign=4273f16b153e39d271eb0ce25bab760e' data =requests.get(url,headers=headers).json() musicList =data['data']['musicList'] for music in musicList: name =music['name'] sid =music['id'] artist =music['artist'] album =music['album'] albumPic =music['albumPic'] vip =music['payInfo']['feeType']['vip'] print(vip,name,artist,album,sid,albumPic) music_mv =requests.get(f'https://bd-api.kuwo.cn/api/service/mv/{sid}',headers=headers).json() try: mv =music_mv['data']['mv']['fileUrl'] print(mv) music_mp3 =requests.get(f'https://bd-api.kuwo.cn/api/service/music/audioUrl/{sid}?reqId=7976a851a2352fbe2705537f374d0548&t=0.40876279858257214',headers=headers).json() audioUrl =music_mp3['data']['audioUrl'] print(audioUrl) except Exception as e: print(f"错误:{e}") continue # 如果出现异常则重试