首页 > 编程语言 >python爬取音乐小工具

python爬取音乐小工具

时间:2024-09-03 11:47:39浏览次数:9  
标签:cookies en python 音乐 b8f2e33447143b75e7e4463e224d6b7f 爬取 json Hm response

import requests
cookies = {
'Hm_lvt_b8f2e33447143b75e7e4463e224d6b7f': '1725333776',
'HMACCOUNT': '15050700AD9FD996',
'Hm_lpvt_b8f2e33447143b75e7e4463e224d6b7f': '1725333791',
'mode': '1',
'songIndex': '0',
'coin_screen': '1707*1067',
}

headers = {
'Accept': 'application/json, text/javascript, /; q=0.01',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
# 'Cookie': 'Hm_lvt_b8f2e33447143b75e7e4463e224d6b7f=1725333776; HMACCOUNT=15050700AD9FD996; Hm_lpvt_b8f2e33447143b75e7e4463e224d6b7f=1725333791; mode=1; songIndex=0; coin_screen=1707*1067',
'Origin': 'http://music.2t58.com',
'Proxy-Connection': 'keep-alive',
'Referer': 'http://music.2t58.com/song/ZGN3c3hrbg.html',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0',
'X-Requested-With': 'XMLHttpRequest',
}

data = {
'id': 'ZGN3c3hrbg',
'type': 'music',
}

response = requests.post('http://music.2t58.com/js/play.php', cookies=cookies, headers=headers, data=data, verify=False)
print(response.json())
res=requests.get(
url=response.json().get("url")
)
with open(f'{response.json().get("title")}.mp3', 'wb') as f:
f.write(res.content)

标签:cookies,en,python,音乐,b8f2e33447143b75e7e4463e224d6b7f,爬取,json,Hm,response
From: https://www.cnblogs.com/yuanyongsheng/p/18394257

相关文章