![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/c85ef5431397ac7e562628700fcfb313.png)
import requests,openpyxl
wb = openpyxl.Workbook()
sheet = wb.active
sheet.title = 'song'
sheet['A1'] ='歌曲名'
sheet['B1'] ='所属专辑'
sheet['C1'] ='播放时长'
sheet['D1'] ='播放链接'
import requests,openpyxl
wb=openpyxl.Workbook()
sheet=wb.active
sheet.title='restaurants'
sheet['A1'] ='歌曲名'
sheet['B1'] ='所属专辑'
sheet['C1'] ='播放时长'
sheet['D1'] ='播放链接'
url = 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp'
for x in range(5):
params = {
'ct': '24',
'qqmusic_ver': '1298',
'new_json': '1',
'remoteplace': 'txt.yqq.song',
'searchid': '64405487069162918',
't': '0',
'aggr': '1',
'cr': '1',
'catZhida': '1',
'lossless': '0',
'flag_qc': '0',
'p': str(x + 1),
'n': '20',
'w': '周杰伦',
'g_tk': '5381',
'loginUin': '0',
'hostUin': '0',
'format': 'json',
'inCharset': 'utf8',
'outCharset': 'utf-8',
'notice': '0',
'platform': 'yqq.json',
'needNewCode': '0'
}
res_music = requests.get(url, params=params)
json_music = res_music.json()
list_music = json_music['data']['song']['list']
for music in list_music:
name = music['name']
album = music['album']['name']
time = music['interval']
link = 'https://y.qq.com/n/yqq/song/' + str(music['mid']) + '.html\n\n'
sheet.append([name,album,time,link])
print('歌曲名:' + name + '\n' + '所属专辑:' + album +'\n' + '播放时长:' + str(time) + '\n' + '播放链接:'+ link)
wb.save('a.xlsx')