import requests
import re
api = 'http://music.taihe.com/search?'
header = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'
}
data = {
'key': '薛之谦'
}
response = requests.get(api, params=data, headers=header)
response.encoding = 'utf-8'
html = response.text
sids = re.findall(r'data-playdata="(.+?)"', 'html', re.S)
print(sids)
da1 = re.findall(r'\d+', sids[0])
print(da1)
for i in da1:
url = r'http://music.taihe.com/data/tingapi/v1/restserver/ting?method=baidu.ting.ugccenter.checkFollRedPoint×tamp={}¶m=qTPtZ4RJPty%2BSRTk9J2nlD%2FpisYR9p8jVnkaoeV5DaI%3D&