Python下载盗墓笔记周建龙版

一个月前的操作,代码不太完善,仅做参考。

#喜马拉雅——盗墓笔记
import requests,re,time,os

headers = {"user-agent":"Mizilla/5.0"}

def download_mp4(song_id,song_name):
	os.makedirs('盗墓笔记周建龙版',exist_ok=True)
	name_path=f'盗墓笔记周建龙版\{song_name}.mp4'
	url = f'https://www.ximalaya.com/revision/play/v1/audio?id={song_id}&ptype=1'
	response = requests.get(url,headers=headers)
	mp4_url=response.json()['data']['src']
	data = requests.get(mp4_url,headers=headers).content
	with open(name_path,'wb') as f:
		f.write(data)
	print('Ok')




def get_name_id(num):
	url=f'https://www.ximalaya.com/youshengshu/3544633/p{num}'
	response = requests.get(url,headers=headers)
	html=response.text
	data=re.findall(r'_Vc">,html)
	for num in range(0,30):
		song_name=data[num][0]
		song_id=data[num][1].split('/')[-1]
		download_mp4(song_id,song_name)
		print(f'{song_name}已经下载完成')
		time.sleep(3)
print('Ok')

for num in range(2,13):   #数字代码仅做参考,可以去页面观察
	get_name_id(num)

                                              ╮(╯▽╰)╭

Python下载盗墓笔记周建龙版_第1张图片

你可能感兴趣的:(Python下载盗墓笔记周建龙版)