抓包: 下载抓包软件Charles https://www.charlesproxy.com/download/
配置: https://blog.csdn.net/HeyShHeyou/article/details/90045204
抓包手机应用: 手机和电脑在同一网络下,设置手机wifi代理,主机和端口
Requests设置请求头Headers: https://blog.csdn.net/ysblogs/article/details/88530124
requests 请求头_requests快速构造请求头的方法:
https://blog.csdn.net/weixin_39905695/article/details/110770593
python: requests:发送http请求 urllib.request:根据url和名字下载图片到指定路径 json:把str转成json格式 os:根据名字创建文件夹
1,抓包查看所有音频类型,,id,name
#构造简单请求头
headers = {
# "Host": "api.psy-1.com",
# "Connection": "keep-alive",
"packageid": "12",
# "user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF XWEB/6500",
# "Content-Type": "application/json",
# "channelid": "2",
# "referer": "https://servicewechat.com/wxf9e01cdca4779ccb/85/page-frame.html",
# "xweb_xhr": "1",
"platformid": "3",
# "token": "374d74285154922b7f1f1150d985102d",
"version": "7",
# "Accept": "*/*",
# "Sec-Fetch-Site": "cross-site",
# "Sec-Fetch-Mode": "cors",
# "Sec-Fetch-Dest": "empty",
# "Accept-Encoding": "gzip, deflate, br",
# "Accept-Language": "zh-CN,zh"
}
#请求路径
urltest = 'https://api.psy-1.com/miniapp/v1/music/tag'
#发送http请求
response = requests.get(url=url,headers=headers,verify=False)
#获取响应数据
html = re.text
#str转json
j = json.loads(html)
#获取data数据
data = j["data"]
typeDict = dict()
#把数据存入字典方便使用
for item in data:
name = item['tag_name']
id = item["tag_id"]
typeDict[id] = name
return typeDict
2,抓包查看单个类别的信息 ![[@B@ELFO5~})A2_MNG)(87K3.png]]
url = 'https://app/v1/tag/music
response = requests.get(url=url,headers=headers,verify=False)
html = response.text
j = json.loads(html)#str转json
data = j["data"]#获取data数据
根据上面抓包音频类型获得的类别名字创建文件夹用来存放不同类型的音频
os.mkdir(r"D:\zsh\video\audio\%s"%typrName)
#循环取出所有数据
for item in data:
audioName = item["musicdesc"]#获取视频的name
audioUrl = item["musicurl"]#获取到宝宝里6个视频的url
# with open('audio.txt','a',encoding='utf-8') as f:
# f.write(audioUrl+'\n')
#取一个下载一个音频
request.urlretrieve(audioUrl,r"D:\zsh\video\audio\%s\%s.mp3"%(typrName,audioName))#下载音频