# -*- 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)