url地址:aHR0cHM6Ly93d3cuZ2VxdWJhby5jb20v
base64解码一下就可以
我使用的是edge浏览器,抓包分析条就是主页的数据包,对于第一次使用edge的开发者工具的,可以使用快捷键Ctrl + shift + i i就是inspect 检查的意思。
在这个数据包中搜索第一条歌曲的名字,可以看到音乐的id信息
这个时候可以使用Python的re模块的findAll方法匹配出所有的/music/数字, 具体的可以使用chatgpt开写代码,毕竟ai时代都是面向gpt编程。匹配出id信息之后,我们继续查看歌曲详情页的信息。在歌曲的详情页中有一个接口信息
其中id就是我们在搜索也中可以匹配到的id信息。
这个接头的响应是:
在获取到的相应中data中的url地址就是音乐的播放地址。
那么这个网站的整体思路已经出来的
1.获取主页的详情页信息,使用Python的re模块提取出每一首歌曲的id信息,使用id请求
接口:https://www.gequbao.com/api/play_url?id={歌曲id}&json=1
就可以了,这个网站并没有反爬措施,正常请求就可以,但是会有一个访问频率的问题,如果访问过快可能导致404,没有获取到信息。
具体的代码信息如下:
import time
import requests
import json
import re
songerList = ["dj"]
headers = {
"referer": "https://www.gequbao.com/",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
}
url = "https://www.gequbao.com/s/"
for songerName in songerList:
url += songerName
response = requests.get(url, headers=headers)
res = response.text
matchs = re.findall("/music/\d+", res)
for match in matchs:
songId = match[7:]
print(songId)
songInfoUrl = "https://www.gequbao.com/api/play_url?id={}&json=1".format(songId)
# print(songInfoUrl)
try:
# print(requests.get(songInfoUrl).text)
time.sleep(5)
mp3Url = json.loads(requests.get(songInfoUrl).text)
# print()
songData = requests.get(mp3Url['data']['url']).content
with open(songId + ".mp3", mode='wb') as f:
f.write(songData)
f.flush()
print("下载成功")
except Exception as e:
# print("")
print(e)
继续加油!