admin 管理员组文章数量: 887021
import json import requests # 伪装自己 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'} # 音乐列表 list_url = 'https://complexsearch.kugou/v2/search/song?callback=callback123&srcappid=2919&clientver=1000&clienttime=1667288844594&mid=e7e1f8d8b618c3f97c2aba28b4f55b26&uuid=e7e1f8d8b618c3f97c2aba28b4f55b26&dfid=1JdK2h1LxMaA3uebLz1TBsjA&keyword=%E5%91%A8%E6%9D%B0%E4%BC%A6&page=1&pagesize=30&bitrate=0&isfuzzy=0&inputtype=0&platform=WebFilter&userid=0&iscorrection=1&privilege_filter=0&filter=10&token=&appid=1014&signature=e729fe24eb3bbd3963c159c425563779' list_resp = requests.get(list_url, headers=headers) # 数据抽取 song_list = json.loads(list_resp.text[12:-2])['data']['lists'] for i, s in enumerate(song_list): print(f'{i + 1}----{s.get("SongName")}----{s.get("FileHash")}') num = input('请输入要下载第几首音乐:') # 音乐信息的url地址 info_url = f'https://wwwapi.kugou/yy/index.php?r=play/getdata&callback=jQuery19105948252723123195_1667288452509&hash={song_list[int(num) - 1].get("FileHash")}&dfid=1JdK2h1LxMaA3uebLz1TBsjA&appid=1014&mid=e7e1f8d8b618c3f97c2aba28b4f55b26&platid=4&album_id=966846&album_audio_id=32100650&_=1667288452511' # headers2 = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36', 'Cookie': 'kg_mid=e7e1f8d8b618c3f97c2aba28b4f55b26; kg_dfid=1JdK2h1LxMaA3uebLz1TBsjA; kg_dfid_collect=d41d8cd98f00b204e9800998ecf8427e; kg_mid_temp=e7e1f8d8b618c3f97c2aba28b4f55b26; Hm_lvt_aedee6983d4cfc62f509129360d6bb3d=1667285044,1667308636; Hm_lpvt_aedee6983d4cfc62f509129360d6bb3d=1667308636' } info_resp = requests.get(info_url,headers = headers2) print(info_resp.json()['data']['play_url']) #这里是自己在csdn上面找的办法但是没用 def getHTMLText(url): maxTryNum = 20 for tries in range(maxTryNum): try: kv = {"user-agent": "Mizilla/5.0"} response = requests.get(url, headers=kv, timeout=60) return response.text except: if tries < (maxTryNum - 1): continue else: print("Has tried %d times to access url %s, all failed!" % (maxTryNum, url)) break
版权声明:本文标题:报错,求求解决,萌新照着教程敲的但是报错,无法解决找了好多方法。Traceback (most recent call last): 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1726377691h948260.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论