博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
喜玛拉雅——徐薇翻唱合集
阅读量:6998 次
发布时间:2019-06-27

本文共 1176 字,大约阅读时间需要 3 分钟。

import requests import json import re # 获取URL网址 start_url = 'https://www.ximalaya.com/revision/play/album?albumId=243032&pageNum={}&sort=-1&pageSize=30' page=1 for page in range(1,3):     url=start_url.format(page)     headers={'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0'}     json_str=requests.get(url,headers=headers).text     # print(json_str)     re_url='src":(.*?),"hasBuy"'     re_title = '"trackName":(.*?),"trackUrl"'     music_title=re.findall(re_title,json_str)     music_url=re.findall(re_url,json_str)     for xima_title,xima_music in zip(music_title,music_url):         title = xima_title         music_wz=xima_music         remove_str_title= json.loads(title)         remove_str_url = json.loads(music_wz)         print(remove_str_title)         print(remove_str_url)         print(type(remove_str_title))         print(type(remove_str_url))         music=requests.get(remove_str_url,headers=headers)         with open('徐薇/{}.mp3'.format(remove_str_title),'wb') as f:             f.write(music.content)             print('正在下载{}'.format(remove_str_title))

转载于:https://www.cnblogs.com/LQ970811/p/10518920.html

你可能感兴趣的文章