# -*- coding: utf-8 -*- import requests import re headers={ 'user-agent':'Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.4068.4 Safari/537.36' } def get_music(num): for i in range(0,int(num)+1): url='https://www.tukuppt.com/yinxiao/j103/zonghe_0_0_0_0_0_0_{}.html'.format(i) response=requests.get(url,headers=headers) #print(response.text) music_url=re.findall("""<source src="(.*?)" type="audio/mpeg">""",response.text) music_name=re.findall("""<a class='title' target="_blank" href=".*?">(.*?)</a>""",response.text) #print(music_url) #print(music_name) for x in range(len(music_name)): content=requests.get("https:"+music_url[x],headers=headers).content with open('image/'+music_name[x]+'.mp3','wb') as f: f.write(content) print('over'+music_name[x]) num=input('输入页数:') get_music(num)
python应用正则爬铃声网站并实现下载
阅读:3170 输入:2020-03-17 21:27:48
- 上一篇:python爬百度图片并保存,提交多数据
- 下一篇:python修改远程计算机密码