freemp3网站搜索接口获取

import requests

cookies = {
    '__tins__20150531': '%7B%22sid%22%3A%201708134527123%2C%20%22vd%22%3A%201%2C%20%22expires%22%3A%201708136327123%7D',
    '__51cke__': '',
    '__51laig__': '1',
}

headers = {
    'authority': 'music.sharerj.com',
    'accept': 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'no-cache',
    'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    # Requests sorts cookies= alphabetically
    # 'cookie': '__tins__20150531=%7B%22sid%22%3A%201708134527123%2C%20%22vd%22%3A%201%2C%20%22expires%22%3A%201708136327123%7D; __51cke__=; __51laig__=1',
    'origin': 'https://music.sharerj.com',
    'pragma': 'no-cache',
    'referer': 'https://music.sharerj.com/',
    'sec-ch-ua': '"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
    'x-requested-with': 'XMLHttpRequest',
}


#
# data = {
# 'types': 'search',
# 'count': '20',
# 'source': 'undefined',
# 'pages': '1',
# 'name': '周杰伦',
# }

# response = requests.post('https://music.sharerj.com/api.php', params=params,
#                          cookies=cookies, headers=headers, data=json.dumps(data).encode(),verify=False)
data = 'types=search&count=20&source=undefined&pages=1&name=星弟'.encode()

response = requests.post('https://music.sharerj.com/api.php',
                         cookies=cookies, headers=headers, data=data,verify=False)

# print(response.json())
for item in response.json():
    print(item['name'],item['id'])
    data = {
        'types': 'url',
        'id': item['id'],
        'source': 'netease',
    }

    response = requests.post('https://music.sharerj.com/api.php', cookies=cookies, headers=headers,
                             data=data, verify=False)
    print(item['name'],response.json()['url'])
   

在这里插入图片描述