输入歌手给出前十首歌
Posted kyx599
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了输入歌手给出前十首歌相关的知识,希望对你有一定的参考价值。
#bs4的使用
import re
import requests
from urllib import error
from bs4 import BeautifulSoup
import os
url = ‘https://c.y.qq.com/soso/fcgi-bin/client_search_cp‘
list_singer = input("请输入你所需要十大评论的人名:")
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",}
singer = list_singer
params = {
‘ct‘: ‘24‘,
‘qqmusic_ver‘: ‘1298‘,
‘new_json‘: ‘1‘,
‘remoteplace‘: ‘txt.yqq.song‘,
‘searchid‘: ‘59258368198185505‘,
‘t‘: ‘0‘,
‘aggr‘: ‘1‘,
‘cr‘: ‘1‘,
‘catZhida‘: ‘1‘,
‘lossless‘: ‘0‘,
‘flag_qc‘: ‘0‘,
‘p‘: ‘1‘,
‘n‘: ‘10‘,
‘w‘: ‘‘,
‘g_tk‘: ‘5381‘,
‘loginUin‘: ‘0‘,
‘hostUin‘: ‘0‘,
‘format‘: ‘json‘,
‘inCharset‘: ‘utf8‘,
‘outCharset‘: ‘utf-8‘,
‘notice‘: ‘0‘,
‘platform‘: ‘yqq.json‘,
‘needNewCode‘: ‘0‘
}
params[‘w‘] = list_singer
res = requests.get(url,params=params,headers = headers)
m_json = res.json()
list_song_name = m_json[‘data‘][‘song‘][‘list‘]
#for song in list_song_name:
#print(song[‘name‘])
以上是关于输入歌手给出前十首歌的主要内容,如果未能解决你的问题,请参考以下文章