在使用reques.post时,提取不到想要的数据,如下
全部代码如下:
import requests
data='{"comm":{"cv":4747474,"ct":24,"format":"json","inCharset":"utf-8","outCharset":"utf-8","notice":0,"platform":"yqq.json","needNewCode":1,"uin":"1152921505070602792","g_tk_new_20200303":35302005,"g_tk":35302005},"req_1":{"method":"DoSearchForQQMusicDesktop","module":"music.search.SearchCgiService","param":{"remoteplace":"txt.yqq.top","searchid":"56240578190918313","search_type":0,"query":"周杰伦","page_num":1,"num_per_page":10}}}'
headers={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53'}
res_music = requests.post('https://u.y.qq.com/cgi-bin/musics.fcg?_=1654010827439&sign=zzbc c11cacfdfmv7flnso1xmfkylfpv9a4e4789a8',data=data.encode('utf-8'),headers=headers)
json_music = res_music.json()
print(json_music)
list_music = json_music['req_1']['data']['body']['song']
print(list_music)
请问是哪里出错,是headers或者data错了吗?